@smartkomm/plexus-cli 0.1.126 → 0.1.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs
CHANGED
|
@@ -6703,8 +6703,11 @@ even greyed out.
|
|
|
6703
6703
|
- **It is read afresh on every load.** A stage change shows or hides the entry on the next load.
|
|
6704
6704
|
- **It rules the offer, never the round.** Tasks a press already spawned stay when the
|
|
6705
6705
|
condition turns false, and they keep holding the decision until they are closed.
|
|
6706
|
-
- **
|
|
6707
|
-
|
|
6706
|
+
- **In \`requiresOneOf\` it counts only while offered.** With \`--requires-one-of interview,taster\`
|
|
6707
|
+
and \`taster\` conditional: where the condition is true the decision waits for one of the two,
|
|
6708
|
+
where it is false only for \`interview\`. If no listed action is offered, the decision is free.
|
|
6709
|
+
A finished \`taster\` stops counting when the condition turns false; a running one keeps holding
|
|
6710
|
+
the decision until its tasks are closed.
|
|
6708
6711
|
|
|
6709
6712
|
## CLI
|
|
6710
6713
|
|
|
@@ -6732,7 +6735,6 @@ In the workflow IDE: node \u2192 \u201EOptionale Aktionen" \u2192 \u201ENur anbi
|
|
|
6732
6735
|
| \`[optionalAction/when]\` with \`condition/*\` | The checker refuses it: unreadable, not yes/no, an unknown leaf, a form address, a literal on an unstable leaf such as \`run.key\` |
|
|
6733
6736
|
| \`[optionalAction/when]\` with \`env/unknownStageKey\` | No stage of the offer's program has this key |
|
|
6734
6737
|
| \`[optionalAction/when]\`, \u201Enames no key of this school" | A \`$env.unit.key\` or \`$env.offer.key\` literal no row has |
|
|
6735
|
-
| \`[decision/requiresOneOfConditional]\` | The decision rule names this action |
|
|
6736
6738
|
|
|
6737
6739
|
A press that arrives anyway while the condition is false is refused with
|
|
6738
6740
|
\`[optionalAction/conditionFalse]\`.
|
|
@@ -6743,7 +6745,8 @@ A press that arrives anyway while the condition is false is refused with
|
|
|
6743
6745
|
2. Cockpit, on the decision node: \u201EWeiteres" lists the entry only on the first one.
|
|
6744
6746
|
3. Press it there: its tasks appear. Change the stage: the entry goes, the task stays.
|
|
6745
6747
|
|
|
6746
|
-
Test tenant: Grundschule, \u201EEinschulung kl\xE4ren" on the Freigabe (offered only for Klassenstufe 1
|
|
6748
|
+
Test tenant: Grundschule, \u201EEinschulung kl\xE4ren" on the Freigabe (offered only for Klassenstufe 1,
|
|
6749
|
+
listed in its decision rule: the buttons in front name it only there).
|
|
6747
6750
|
`,"references/offer/consent-field.md":`# Add a consent field (Zustimmungsfeld)
|
|
6748
6751
|
|
|
6749
6752
|
**When to use:** a form must ask the family to agree to something \u2014 the privacy
|
|
@@ -10938,7 +10941,7 @@ plexus-cli --env prod jobs list --status running # nothing unexpectedly in
|
|
|
10938
10941
|
## Related
|
|
10939
10942
|
- Command reference: \`plexus-cli jobs list --help\`, \`plexus-cli platform workers reap --help\`,
|
|
10940
10943
|
\`plexus-cli platform imports cleanup-orphaned --help\`.
|
|
10941
|
-
`};var Qu="d96a32682671e6a8f70a38029a4d9aa6ef08447ef43eb61f348c6c4acd594126",Ug=PR;var Gg=class extends xe{static{s(this,"AgentToolsCommand")}static paths=[["agent","tools"]];static usage=$.Usage({category:"Agents",description:"Show the shared platform/CLI agent tool schemas and skill revision."});async execute(){return this.print({skillHash:Qu,tools:ll}),0}},zg=class extends xe{static{s(this,"AgentInvokeCommand")}static paths=[["agent","invoke"]];static usage=$.Usage({category:"Agents",description:"Invoke a shared agent tool; pipe its JSON input on stdin."});tool=f.String("--tool",{required:!0,description:"plexus|plexus_skill|plexus_workspace"});async execute(){if("isTTY"in this.context.stdin&&this.context.stdin.isTTY===!0)throw new Error("plexus: pipe the tool's JSON input on stdin.");let n=JSON.parse(await Vg(this.context.stdin)),t=await this.context.executePlexusAgentTool(this.tool,n);return this.print(t),0}},NR=[Gg,zg];var Wg=[{key:"fixture_test",email:"test@example.com",firstName:"Test",lastName:"Bewerber"}],Eae=new Set(Wg.map(e=>e.key));function CR(e,n,t,r){let i=e.flatMap(l=>l.angebote).find(l=>l.offerKey===n);if(i===void 0){let l=e.flatMap(d=>d.angebote.map(c=>c.offerKey));throw new Error(`applications start-test: no offer "${n}" (offers: ${l.join(", ")||"none"})`)}let o=i.stages.find(l=>l.stageKey===r||l.stageId===r);if(o===void 0){let l=i.stages.map(d=>`${d.stageKey} (${d.stageId})`);throw new Error(`applications start-test: no level "${r}" in ${n} \u2014 name it by key or id: ${l.join(", ")}`)}let a=o.runs.find(l=>l.runKey===t||l.runId===t);if(a===void 0){let l=o.runs.map(d=>`${d.runKey} (${d.runId})`);throw new Error(`applications start-test: no school year "${t}" for level ${o.stageKey} \u2014 name it by key or id: ${l.join(", ")}`)}if(!a.isOpen)throw new Error(`applications start-test: school year ${a.runKey} is closed for level ${o.stageKey}`);return{programRunId:a.runId,programStageId:o.stageId}}s(CR,"resolveStartTarget");function JG(e){return e.kind==="named"?e.name:`(${e.standIn??e.fallback})`}s(JG,"applicantText");function DR(e){return e.map(n=>({id:n.application._id,status:n.deletedAt?`${n.application.status} (gel\xF6scht)`:n.application.status,state:n.currentProcessStateId??"",applicant:JG(n.applicantName),test:n.application.testMode===!0?"test":""}))}s(DR,"applicationRows");var _R=Wg.map(e=>e.email);function FR(e,n,t,r){if(t===void 0&&r===void 0)throw new Error("applications start-test: name the applicant \u2014 --party <partyId> or --applicant <email>");if(t!==void 0&&r!==void 0)throw new Error("applications start-test: --party or --applicant, not both");if(Kg(e,n)&&(r===void 0||!_R.includes(r.trim().toLowerCase())))throw new Error(`applications start-test: on prod only for the test account ${_R.join(", ")} (--applicant) \u2014 never a real family's`)}s(FR,"assertStartApplicant");function LR(e){let n={};for(let{address:t,...r}of e.entries)n[t]=r;return{applicationId:e.applicationId,store:n}}s(LR,"processStoreJson");function QG(e){switch(e.kind){case"form":return`form ${e.formInstanceId} (${e.state})`;case"document":return e.file===null?`document ${e.slotKey} (leer)`:`document ${e.slotKey} \xB7 v${e.file.versionNumber} ${e.file.filename??e.file.artifactId}`;case"contract":return`contract ${e.contractId} \xB7 ${e.revision===null?"keine Fassung":`Fassung ${e.revision.revisionNumber}`} \xB7 ${e.contractStatus}`;case"contracts":return e.contracts.map(n=>`${n.partKey}: contract ${n.contractId} \xB7 ${n.revision===null?"keine Fassung":`Fassung ${n.revision.revisionNumber}`} \xB7 ${n.contractStatus}`).join("; ")}}s(QG,"refText");function ZG(e){return e.state!=="present"?e.reason?.de??"":e.ref!==void 0?QG(e.ref):JSON.stringify(e.value)}s(ZG,"holds");function MR(e){return e.entries.map(n=>({address:n.address,state:n.state,holds:ZG(n),producer:n.producer?.label??"",written:n.writtenAt===void 0?"":new Date(n.writtenAt).toISOString()}))}s(MR,"storeRows");function Zu(e){let n={},t={};for(let r of e){let i=r.indexOf("=");if(i<=0)throw new Error(`Expected key=value, got '${r}'.`);let o=r.slice(0,i);if(Object.hasOwn(t,o))throw new Error(`'${o}' is given twice.`);let a=r.slice(i+1);t[o]=a;try{n[o]=JSON.parse(a)}catch{n[o]=a}}return{values:n,raw:t}}s(Zu,"parseKv");var qR="started",Xu="submitted",ef="submitted",KR="load-scenario:";var jR="(Bewerbung)";function BR(e){return{nodeId:jR,actions:e.map(n=>({id:n.id,label:{de:`${n.label??n.id}${n.count===void 0?"":` (${n.count})`}`,en:`${n.label??n.id}${n.count===void 0?"":` (${n.count})`}`},...n.disabledReason===void 0?{}:{disabledReason:n.disabledReason}}))}}s(BR,"sharedAsList");function VR(e){return e.disabledReason===void 0?"":e.disabledCount===void 0?e.disabledReason:`${e.disabledReason} (${e.disabledCount})`}s(VR,"disabledText");function UR(e){return e.flatMap(({nodeId:n,actions:t})=>t.map(r=>({node:n,action:r.id,label:r.label.de,disabled:VR(r)})))}s(UR,"actionRows");function GR(e,n,t=[]){let r=e.filter(({actions:d})=>d.some(c=>c.id===n));if(r.length===0){let d=[...new Set(e.flatMap(({actions:c})=>c.map(u=>u.id)))];throw new Error(`test-actions run: no current node offers "${n}" (offered: ${d.join(", ")||"nothing"})`)}if(r.length>1)throw new Error(`test-actions run: "${n}" is offered by ${r.map(d=>d.nodeId).join(", ")} \u2014 pass --node`);let{nodeId:i,actions:o}=r[0],a=o.find(d=>d.id===n);if(a.disabledReason!==void 0)throw new Error(`test-actions run: "${n}" on ${i} is disabled: ${VR(a)}`);if(i!==jR)return i;let l=t[0];if(l===void 0)throw new Error(`test-actions run: "${n}" needs a current node \u2014 the application has none`);return l}s(GR,"nodeOfferingAction");function zR(e,n,t){if(e.startsWith(KR)){if(Object.hasOwn(t,"autoSubmit"))throw new Error(`test-actions run: ${e}: a scenario's autoSubmit is set by --auto-submit / --no-auto-submit, not --param`);return{autoSubmit:n,...t}}return Object.keys(t).length===0?void 0:{...t}}s(zR,"runParams");async function XG(e,n){let t=await e.query(x.workflow.getInstance,{applicationId:n});if(t===null)throw new Error(`test-actions: application ${n} has no workflow instance`);return t.instance.currentNodeIds}s(XG,"currentNodeIds");function ez(e,n){switch(n){case"notTestApplication":return`${e} is not a test application`;case"completed":case"aborted":case"deleted":return`${e} is ${n} \u2014 test actions run only on an active application`;case"missingPermission":return"the caller lacks bewerbungsmanagement.testActions.run"}}s(ez,"refusalText");async function nf(e,n,t){let r=await e.query(x.workflow.listSharedTestActions,{applicationId:n});if(!r.permitted)throw new Error(`test-actions: not permitted \u2014 ${ez(n,r.reason)}`);let i=[];for(let o of t){let a=await e.query(x.workflow.listTestActions,{applicationId:n,nodeId:o});if(a===null)throw new Error(`test-actions: node "${o}" is not in this application's workflow (or it has no instance)`);i.push({nodeId:o,actions:a})}return[...i,BR(r.actions)]}s(nf,"actionsOf");async function WR(e,n,t){return t!==void 0?[t]:await XG(e,n)}s(WR,"nodesOf");var Yg=class extends D{static{s(this,"TestActionsListCommand")}static paths=[["test-actions","list"]];static usage=$.Usage({category:"Admission",description:"List the test-mode actions of the application's current node(s) (scenarios, auto-fill-files, submit, \u2026) and the application-wide ones"});application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});async execute(){let n=await this.caller(),t=await nf(n,this.application,await WR(n,this.application,this.node));return this.print(t,UR,["node","action","label","disabled"]),0}},Hg=class extends D{static{s(this,"TestActionsRunCommand")}application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});static paths=[["test-actions","run"]];static usage=$.Usage({category:"Admission",description:"Run one test-mode action; a scenario (load-scenario:<id>) also submits unless --no-auto-submit"});action=f.String("--action",{required:!0,description:"Action id, e.g. load-scenario:standard, auto-fill-files, submit-form"});autoSubmit=f.Boolean("--auto-submit",!0,{description:"Scenario only: stub the file fields and submit after loading (default on; --no-auto-submit only loads)"});param=f.Array("--param",{description:"Action parameter key=value (repeatable; the value is JSON where it parses, else text), e.g. --param confirmed=true for an action that asks a question first (its `confirm` in `test-actions list`)"});async execute(){let n=zR(this.action,this.autoSubmit,Zu(this.param??[]).values),t=await this.caller(),r=this.application,i=await WR(t,this.application,this.node),o=GR(await nf(t,r,i),this.action,i);return await t.mutation(x.workflow.runTestAction,{applicationId:r,nodeId:o,actionId:this.action,...n===void 0?{}:{params:n}}),this.print({ran:this.action,on:o},a=>[{key:"ran",value:a.ran},{key:"on",value:a.on},{key:"next",value:"test-actions list \u2014 file fills and the submit after them run asynchronously"}]),0}},YR=[Yg,Hg];var We=["de","en"];function hs(e,n){return We.every(t=>e[t]===n[t])}s(hs,"sameText");function Rn(e){if(e===null||typeof e!="object"||Array.isArray(e))return"not-localized";let n=e;return Object.keys(n).some(r=>!We.includes(r))?"not-localized":We.filter(r=>{let i=n[r];return typeof i!="string"||i.trim()===""})}s(Rn,"missingLocales");function $i(e){let n=Rn(e);return n!=="not-localized"&&n.length===0}s($i,"isLocalizedText");function dl(e,n){let t={};for(let r of We){let i=e.map(o=>o[r]);t[r]=i.every(o=>typeof o=="string"&&o.trim()!=="")?n(i,r):""}return t}s(dl,"composeTexts");var fr=/^[a-z][A-Za-z0-9]*$/;function Jg(e){return typeof e=="string"&&fr.test(e)}s(Jg,"isNodeId");function gs(e,n){Jg(e)||F(`[graph/nodeIdFormat] "${e}" cannot name a node: a node id is ${fr.source}.`);let t=new Set(n);if(!t.has(e))return e;let r=2;for(;t.has(`${e}${r}`);)r++;return`${e}${r}`}s(gs,"makeNodeId");var Ri="$env";function se(e){if(e.scope==="env")return`${Ri}.${e.key}`;let n=e.scope==="derived"?`$derived.${e.key}`:`$${e.scope}.${e.owner}.${e.key}`;return e.path===void 0?n:`${n}.${e.path}`}s(se,"formatAddress");var Cr=/^[a-z][a-zA-Z0-9_]*$/,nz=/^[A-Za-z_][A-Za-z0-9_]*$/;function po(e){return typeof e=="string"&&e.split(".").every(n=>nz.test(n))}s(po,"isPath");function Zr(e){if(!e.startsWith("$"))return null;let n=e.slice(1).split("."),[t,...r]=n;switch(t){case"env":{let i=r.join(".");return r.length>0&&po(i)?{scope:"env",key:i}:null}case"derived":{let[i,...o]=r;return i===void 0||!Cr.test(i)?null:HR({scope:"derived",key:i},o)}case"node":case"task":{let[i,o,...a]=r;return i===void 0||o===void 0||!Cr.test(o)||(t==="node"?!fr.test(i):!Cr.test(i))?null:HR({scope:t,owner:i,key:o},a)}default:return null}}s(Zr,"tryParseAddress");function HR(e,n){if(n.length===0)return e;let t=n.join(".");return po(t)?{...e,path:t}:null}s(HR,"withPath");function we(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let n=e,t=n.scope==="env"?["scope","key"]:n.scope==="derived"?["scope","key","path"]:["scope","owner","key","path"];if(Object.keys(n).some(r=>!t.includes(r))||n.path!==void 0&&!po(n.path))return!1;switch(n.scope){case"env":return po(n.key);case"derived":return typeof n.key=="string"&&Cr.test(n.key);case"node":return typeof n.owner=="string"&&fr.test(n.owner)&&typeof n.key=="string"&&Cr.test(n.key);case"task":return typeof n.owner=="string"&&Cr.test(n.owner)&&typeof n.key=="string"&&Cr.test(n.key);default:return!1}}s(we,"isAddress");var Xr={offer:{key:"string",title:"string"},unit:{key:"string",name:"string"},stage:{key:"string",name:"string",gradeLevel:"number"},run:{key:"string",name:"string",startDate:"date"},applicant:{language:"enum",channel:"enum"}},ys=Object.keys(Xr);function ws(e){return Object.hasOwn(Xr,e)}s(ws,"isEnvKey");var tz=["self-service","staff"];function JR(e,n){return{kind:"fixed",values:e,labels:n}}s(JR,"fixedSet");var tf={of:"applicant.language",withoutValue:"de"},ei={"offer.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Angebot",en:"Offer"}},"offer.title":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Titel des Angebots",en:"Offer title"},nameLanguage:tf},"unit.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Einheit",en:"Unit"}},"unit.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Einheit",en:"Unit name"},nameLanguage:tf},"stage.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Klassenstufe (Schl\xFCssel)",en:"Grade (key)"},cohortBound:!0},"stage.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Klassenstufe",en:"Grade name"},cohortBound:!0,nameLanguage:tf},"stage.gradeLevel":{valueSet:{kind:"open"},nullable:!0,absent:{de:"Die Stufe hat keine Klassenstufe (Kindergarten).",en:"The stage has no grade level (Kindergarten)."},label:{de:"Klassenstufe",en:"Grade level"},cohortBound:!0},"run.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Schuljahr",en:"School year"},cohortBound:!0},"run.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name des Schuljahrs",en:"School year name"},cohortBound:!0,nameLanguage:tf},"run.startDate":{valueSet:{kind:"open"},nullable:!0,absent:{de:"F\xFCr das Schuljahr ist kein Beginn erfasst.",en:"The school year has no start date."},label:{de:"Beginn des Schuljahrs",en:"School year start"},cohortBound:!0},"applicant.language":{valueSet:JR(We,{de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}}),nullable:!0,absent:{de:"Die Bewerbung hat kein Bewerberkonto (intern angelegt).",en:"The application has no applicant account (started by staff)."},label:{de:"Bewerbersprache",en:"Applicant language"}},"applicant.channel":{valueSet:JR(tz,{staff:{de:"intern",en:"in-house"},"self-service":{de:"online (Familie)",en:"online (family)"}}),nullable:!1,label:{de:"Eingangsweg",en:"Intake channel"}}},rf={types:Xr,fields:ei},of=ys.flatMap(e=>Object.keys(Xr[e]).map(n=>`${e}.${n}`));function Wt(e){return Object.hasOwn(ei,e)}s(Wt,"isEnvLeaf");function sf(e){return`${Ri}.${e}`}s(sf,"envIdentifier");function mo(e){let n=ei[e],[t,r]=e.split("."),i=Xr[t][r];i===void 0&&F(`[env] leaf "${e}" has no type`);let o=n.valueSet;return{leaf:e,type:i,label:n.label,nullable:n.nullable,...n.absent===void 0?{}:{absent:n.absent},...n.nameLanguage===void 0?{}:{nameLanguage:n.nameLanguage},...n.cohortBound===void 0?{}:{cohortBound:n.cohortBound},...o.kind==="fixed"?{enumOptions:o.values.map(a=>{let l=o.labels[a];return l===void 0&&F(`[env] "${e}" names the value "${a}" without a label`),{value:a,label:l}})}:{}}}s(mo,"envLeaf");var QR="staffInput";var rz=["boolean"],cl=/^[a-z][A-Za-z0-9]*$/;function af(e){return e.staffInputs??[]}s(af,"staffInputsOf");function lf(e){return`${QR}.${e}`}s(lf,"staffInputLeaf");function ZR(e){return`${Ri}.${lf(e)}`}s(ZR,"staffInputIdentifier");function iz(e){let n=`${QR}.`;return e.startsWith(n)?e.slice(n.length):null}s(iz,"staffInputKeyOfLeaf");function ks(e,n){let t=iz(n);return t===null?void 0:af(e).find(r=>r.key===t)}s(ks,"declaredStaffInput");function XR(e){return[...af(e).map(n=>({leaf:lf(n.key),type:n.type,label:n.label,valueSet:{kind:"open"},nullable:!1,cohortBound:!1})),...of.map(n=>{let t=mo(n);return{leaf:n,type:t.type,label:t.label,valueSet:ei[n].valueSet,nullable:t.nullable,cohortBound:t.cohortBound===!0}})]}s(XR,"envLeavesFor");function eI(e){return XR(e).filter(n=>!n.cohortBound)}s(eI,"conditionEnvLeaves");function nI(e){return rI(eI(e))}s(nI,"envConditionSchemaFor");function oz(e){return XR(e).map(n=>n.leaf==="stage.key"?{...n,valueSet:{kind:"open"}}:n)}s(oz,"offerConditionEnvLeaves");function tI(e){return rI(oz(e))}s(tI,"offerConditionSchemaFor");function rI(e){let n={},t={};for(let{leaf:r,type:i,valueSet:o,nullable:a}of e){let[l="",d=""]=r.split(".");n[l]={...n[l]??{},[d]:i},t[r]={valueSet:o,nullable:a}}return{types:n,fields:t}}s(rI,"schemaOfLeaves");function iI(e){let n=e.staffInputs;if(n===void 0)return[];if(!Array.isArray(n))return[{path:"staffInputs",reason:{de:"[staffInput/shape] graph.staffInputs muss eine Liste sein.",en:"[staffInput/shape] graph.staffInputs must be a list."}}];let t=[],r=new Set;return n.forEach((i,o)=>{let a=`staffInputs[${o}]`,l=i;if(l===null||typeof l!="object"||typeof l.key!="string"){t.push({path:a,reason:{de:"[staffInput/shape] Eine interne Angabe braucht key, type und label ({ de, en }).",en:"[staffInput/shape] An internal entry needs key, type and label ({ de, en })."}});return}let d={de:`Interne Angabe "${l.key}"`,en:`Internal entry "${l.key}"`};cl.test(l.key)||t.push({path:`${a}.key`,reason:{de:`[staffInput/keyFormat] ${d.de}: Schl\xFCssel beginnt mit einem Kleinbuchstaben und enth\xE4lt nur Buchstaben und Ziffern.`,en:`[staffInput/keyFormat] ${d.en}: the key starts with a lowercase letter and contains only letters and digits.`}}),r.has(l.key)&&t.push({path:`${a}.key`,reason:{de:`[staffInput/duplicateKey] ${d.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[staffInput/duplicateKey] ${d.en}: the key is used twice.`}}),r.add(l.key),rz.includes(l.type)||t.push({path:`${a}.type`,reason:{de:`[staffInput/unknownType] ${d.de}: Typ "${String(l.type)}" \u2014 erlaubt ist nur "boolean" (K\xE4stchen).`,en:`[staffInput/unknownType] ${d.en}: type "${String(l.type)}" \u2014 only "boolean" (checkbox) is allowed.`}});let c=Rn(l.label);c==="not-localized"?t.push({path:`${a}.label`,reason:{de:`[staffInput/shape] ${d.de}: label muss { de, en } sein.`,en:`[staffInput/shape] ${d.en}: label must be { de, en }.`}}):c.length>0&&t.push({path:`${a}.label`,reason:{de:`[i18n/missingTranslation] ${d.de}: Beschriftung fehlt in ${c.join(", ")}.`,en:`[i18n/missingTranslation] ${d.en}: label is missing in ${c.join(", ")}.`}})}),t}s(iI,"staffInputIssues");var sy={required:!0,description:"Offer slug (its offerKey)"},Qg=class extends D{static{s(this,"ApplicationsListCommand")}static paths=[["applications","list"]];static usage=$.Usage({category:"Admission",description:"List an offer's applications (id, status, board state, applicant, test)"});offer=f.String("--offer",sy);testOnly=f.Boolean("--test-only",!1,{description:"Only test applications"});async execute(){let n=await this.caller(),t=await n.query(x.admission.listForAngebot,{client:this.requireTenant(n),offerKey:this.offer}),r=DR(t).filter(i=>!this.testOnly||i.test==="test");return this.print(r,i=>i,["id","status","state","applicant","test"]),0}},Zg=class extends D{static{s(this,"ApplicationsCountsCommand")}static paths=[["applications","counts"]];static usage=$.Usage({category:"Admission",description:"Count an offer's applications per list"});offer=f.String("--offer",sy);async execute(){let n=await this.caller(),t=await n.query(x.admission.getCountsByListForAngebot,{client:this.requireTenant(n),offerKey:this.offer});return this.print(t,r=>[...Object.entries(r.counts).map(([i,o])=>({list:i,count:String(o)})),{list:"total",count:String(r.total)}],["list","count"]),0}},Xg=class extends D{static{s(this,"ApplicationsShowCommand")}static paths=[["applications","show"]];static usage=$.Usage({category:"Admission",description:"One application: status, test flag, offer, current workflow nodes"});application=f.String({required:!0});async execute(){let n=await this.caller(),t=this.application,r=await n.query(x.admission.get,{applicationId:t});if(r===null)throw new Error(`applications show: no application ${t} (or not visible to you)`);let i=await n.query(x.workflow.getInstance,{applicationId:t});return this.print({application:r,currentNodes:i?.instance.currentNodeIds??[]},o=>[{key:"id",value:t},{key:"status",value:o.application.status},{key:"test",value:o.application.testMode?"ja":"nein"},{key:"offer",value:o.application.offerId},{key:"current nodes",value:o.currentNodes.join(", ")}]),0}},ey=class extends D{static{s(this,"ApplicationsStoreCommand")}static paths=[["applications","store"]];static usage=$.Usage({category:"Admission",description:"One application's process store: every address of its pinned graph, resolved (present / pending / absent)",details:"Staff only (applications.manage). --json prints one object keyed by the canonical address ($node\u2026, $task\u2026, $derived\u2026, $env\u2026). Values are shown whatever their audience \u2014 never hand the output to the family. Recipe: playbooks/applications/inspect-process-store.md."});application=f.String({required:!0});async execute(){let t=await(await this.caller()).query(x.processStoreView.get,{applicationId:this.application});return this.print(LR(t),()=>MR(t),["address","state","holds","producer","written"]),0}},ny=class extends D{static{s(this,"ApplicationsStartTestCommand")}static paths=[["applications","start-test"]];static usage=$.Usage({category:"Admission",description:"Start a TEST application for an applicant (school year and level by key or id) and show what test mode offers next",details:"Always test mode. --applicant names the account by its login address (on prod only the tenant's test account); --party names the applicant party directly. Without --version it runs on the live generation, like the cockpit."});offer=f.String("--offer",sy);run=f.String("--run",{required:!0,description:"School year: its key or id (never its name)"});stage=f.String("--stage",{required:!0,description:"Level: its key or id (never its name)"});party=f.String("--party",{description:"Applicant party id"});applicant=f.String("--applicant",{description:"Applicant account login address (e.g. the test account test@example.com)"});version=f.String("--version",{description:"Offer version id to test (default: the live generation)"});staffInput=f.Array("--staff-input",{description:"A staff input the offer declares, as key=true|false \u2014 repeat it once per input; a staff start must set every one"});proxy=f.Boolean("--proxy",{description:"Start in Stellvertretung (--proxy) or not (--no-proxy); left out, the tenant's default applies, as in the cockpit"});async execute(){let n=await this.caller();FR(this.resolvedTarget(),this.prodUrls(),this.party,this.applicant);let t=this.requireTenant(n),r=CR(await n.query(x.admission.listAdmissionTree,{client:t}),this.offer,this.run,this.stage),i=this.party;if(this.applicant!==void 0){let d=await n.query(x.applicants.partyByEmail,{client:t,email:this.applicant});if(d===null)throw new Error(`applications start-test: no applicant account ${this.applicant} at this school (create it in the cockpit first)`);i=d}let o=await n.mutation(x.admission.staffStartApplicationForParty,{client:t,offerKey:this.offer,partyId:i,programRunId:r.programRunId,programStageId:r.programStageId,...this.proxy===void 0?{}:{startInProxy:this.proxy},staffInputs:sI(this.staffInput??[]),testMode:!0,...this.version===void 0?{}:{offerVersionId:this.version}}),a,l;try{let d=await n.query(x.workflow.getInstance,{applicationId:o.applicationId});if(d===null)throw new Error("the started application has no workflow instance");a=d.instance.currentNodeIds,l=(await nf(n,o.applicationId,a)).flatMap(c=>c.actions.map(u=>u.id))}catch(d){throw new Error(`applications start-test: started ${o.applicationId}, but reading its state failed: ${d instanceof Error?d.message:String(d)}`,{cause:d})}return this.print({applicationId:o.applicationId,currentNodes:a,testActions:l},d=>[{key:"application",value:d.applicationId},{key:"current nodes",value:d.currentNodes.join(", ")},{key:"test actions",value:d.testActions.join(", ")},{key:"next",value:`test-actions run --application ${d.applicationId} --action <id>`}]),0}},ty=class extends D{static{s(this,"ApplicationsDiscardTestCommand")}static paths=[["applications","discard-test"]];static usage=$.Usage({category:"Admission",description:"Discard a TEST application (the server refuses a real one), or with --all-test every expired one of the school",details:"With an id: discards that test application. With --all-test --older-than <N>d: lists the school's test applications whose last activity is older than N days (N \u2265 14) and that are not kept as a demo \u2014 a dry run unless --confirm; --confirm discards each expired one the server re-checks, the rest are reported with the reason. Recipe: playbooks/applications/expire-test-applications.md.",examples:[["Dry run","plexus-cli --env prod --tenant <t> applications discard-test --all-test --older-than 14d --dry-run"],["Discard","plexus-cli --env prod --tenant <t> --allow-prod applications discard-test --all-test --older-than 14d --confirm"]]});application=f.String({required:!1});allTest=f.Boolean("--all-test",!1,{description:"Every expired test application of the school instead of one id"});olderThan=f.String("--older-than",{description:"With --all-test: days without activity, as <N>d (N \u2265 14)"});dryRun=f.Boolean("--dry-run",!1,{description:"With --all-test: list only (the default)"});confirm=f.Boolean("--confirm",!1,{description:"With --all-test: discard (else the dry run)"});async execute(){if(!this.allTest){if(this.application===void 0)throw new Error("applications discard-test: name an application id, or use --all-test --older-than <N>d");if(this.olderThan!==void 0||this.dryRun||this.confirm)throw new Error("applications discard-test: --older-than, --dry-run and --confirm belong to --all-test");return await(await this.caller()).mutation(x.admission.discardTest,{applicationId:this.application}),this.print({discarded:this.application},u=>[{key:"discarded",value:u.discarded}]),0}if(this.application!==void 0)throw new Error("applications discard-test: --all-test takes no application id");if(this.olderThan===void 0)throw new Error("applications discard-test --all-test: --older-than <N>d is required");if(this.dryRun&&this.confirm)throw new Error("applications discard-test: --dry-run and --confirm exclude each other");let n=sz(this.olderThan),t=await this.caller(),r=this.requireTenant(t),i=[],o=null;for(;;){let c=await t.query(x.admission.testTtlPlan,{client:r,olderThanDays:n,cursor:o});if(i.push(...c.rows),c.isDone)break;o=c.continueCursor}let a=i.map(c=>({...c,result:c.verdict!=="expired"?"kept":c.block!==null?"blocked":this.confirm?"pending":"would discard"})),l=i.filter(c=>c.verdict==="expired"&&c.protectedDemo).map(c=>c.applicationId);if(this.confirm&&l.length>0)throw new Error(`applications discard-test --all-test: protected demo application(s) in the discard set, nothing discarded: ${l.join(", ")}`);let d=0;if(this.confirm)for(let c of a.filter(u=>u.result==="pending"))try{await t.mutation(x.admission.discardExpiredTest,{applicationId:c.applicationId,olderThanDays:n}),c.result="discarded"}catch(u){d++,c.result=`failed: ${u instanceof Error?u.message:String(u)}`}return this.print({olderThanDays:n,confirm:this.confirm,rows:a},c=>c.rows.map(u=>({id:u.applicationId,lastActivity:new Date(u.lastActivityAt).toISOString().slice(0,10),verdict:u.verdict,block:u.block??"",result:u.result})),["id","lastActivity","verdict","block","result"]),d>0?1:0}};function sz(e){let n=/^(\d+)d$/.exec(e.trim());if(n===null)throw new Error(`--older-than "${e}": expected <N>d, e.g. 14d`);return Number(n[1])}s(sz,"parseDays");var ry=class extends D{static{s(this,"ApplicationsSetKeepDemoCommand")}static paths=[["applications","set-keep-demo"]];static usage=$.Usage({category:"Admission",description:"Mark a TEST application \u201EDemo behalten\u201C (never expires, never discarded), or clear the mark with --off"});application=f.String({required:!0});off=f.Boolean("--off",!1,{description:"Clear the mark"});async execute(){return await(await this.caller()).mutation(x.admission.setKeepAsDemo,{applicationId:this.application,keep:!this.off}),this.print({application:this.application,keepAsDemo:!this.off},t=>[{key:"application",value:t.application},{key:"keep as demo",value:t.keepAsDemo?"ja":"nein"}]),0}},iy=class extends D{static{s(this,"ApplicationsStaffInputListCommand")}static paths=[["applications","staff-input","list"]];static usage=$.Usage({category:"Admission",description:"An application's internal inputs (set at the start): value, and why one can no longer be corrected"});application=f.String({required:!0});async execute(){let t=await(await this.caller()).query(x.admission.staffInputsOfApplication,{applicationId:this.application});return this.print(t,r=>r.map(i=>({key:i.key,label:i.label.de,value:String(i.value),correctable:i.block===null?"ja":i.block.de})),["key","label","value","correctable"]),0}},oy=class extends D{static{s(this,"ApplicationsStaffInputSetCommand")}static paths=[["applications","staff-input","set"]];static usage=$.Usage({category:"Admission",description:"Correct one internal input of an application, with a reason \u2014 refused once a node that reads it was entered",examples:[["Untick \u201EKind von Mitarbeitenden\u201C",'plexus-cli --env prod --tenant <t> --allow-prod applications staff-input set <id> --input staffApplication=false --reason "falsch angehakt"']]});application=f.String({required:!0});input=f.String("--input",{required:!0,description:"key=true|false"});reason=f.String("--reason",{required:!0,description:"Why \u2014 recorded on the application's activity feed"});async execute(){let n=await this.caller(),[{key:t,value:r}]=sI([this.input]);return await n.mutation(x.admission.correctStaffInput,{applicationId:this.application,key:t,value:r,reason:this.reason}),this.print({application:this.application,key:t,value:r},i=>[{key:"application",value:i.application},{key:i.key,value:String(i.value)}]),0}},oI=[Qg,Zg,Xg,ey,ny,ty,ry,iy,oy];function sI(e){return e.map(n=>{let[t="",r,...i]=n.split("=");if(!cl.test(t)||r!=="true"&&r!=="false"||i.length>0)throw new Error(`--staff-input "${n}": expected key=true or key=false`);return{key:t,value:r==="true"}})}s(sI,"parseStaffInputs");var Vn="contractGenerator",ho="documentTemplate";function ul(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let n=e,t=Object.keys(n);return(n.kind==="generator"||n.kind==="package")&&typeof n.key=="string"&&n.key.length>0&&(n.revision===void 0||typeof n.revision=="number"&&Number.isInteger(n.revision)&&n.revision>0)&&t.every(r=>r==="kind"||r==="key"||r==="revision")}s(ul,"isGeneratorRef");function aI(e,n){let t=e.inputs?.[n];return t?.kind==="literal"?t.value:void 0}s(aI,"literalOf");function ni(e){let n=aI(e,Vn);return ul(n)?n:null}s(ni,"generatorRefOfNode");function pr(e){let n=aI(e,ho);return typeof n=="string"&&n.length>0?n:null}s(pr,"documentTemplateKeyOfNode");function lI(e){return`${e.kind}:${e.key}${e.revision===void 0?"":`@${e.revision}`}`}s(lI,"generatorRefLabel");var az=["formExports","generatorStamp"];function dI(e,n,t){let r=e.inputs?.[Vn];(r?.kind!=="literal"||!ul(r.value))&&F(`applyGeneratorStamp: the node names no generator in inputs.${Vn} \u2014 a stamp derives from it`),t.freezeRevision&&n.revision!==void 0&&(e.inputs[Vn]={kind:"literal",value:{...r.value,revision:n.revision}}),e.generatorStamp={inputSchema:n.inputSchema,parties:n.parties,schemaDigest:n.schemaDigest,...n.parts===void 0?{}:{parts:n.parts}}}s(dI,"applyGeneratorStamp");var lz=["reads"];function bs(e){if(e===null||typeof e!="object")return e;let n={...e};return Array.isArray(n.nodes)&&(n.nodes=n.nodes.map(t=>{if(t===null||typeof t!="object")return t;let r={...t};for(let i of az)delete r[i];for(let i of lz)Array.isArray(r[i])&&r[i].length===0&&delete r[i];return r})),n}s(bs,"comparableWorkflowGraph");var fl={id:{de:"die Identit\xE4t ist der Slug des Angebots (bundle.yaml slugs.manifest)",en:"the identity is the offer's slug (bundle.yaml slugs.manifest)"},label:{de:"der Titel steht in bundle.yaml `label`",en:"the title is bundle.yaml `label`"},version:{de:"die Revision z\xE4hlt die Datenbank",en:"the database counts the revision"},applicantMode:{de:"von nichts gelesen",en:"read by nothing"},signatureLevel:{de:"von nichts gelesen",en:"read by nothing"},roleInstances:{de:"die Rollen kommen aus den Formular-Effekten",en:"roles come from the form effects"},leistungen:{de:"von nichts gelesen",en:"read by nothing"},capacity:{de:"die Kapazit\xE4t geh\xF6rt der Kohorte (program.runs[].capacities)",en:"capacity belongs to the cohort (program.runs[].capacities)"},progressLayoutId:{de:"von nichts gelesen",en:"read by nothing"},bewerbungsfenster:{de:"die Kohorte besitzt die \xD6ffnung (isOpen / applicationOpensAt)",en:"the cohort owns opening (isOpen / applicationOpensAt)"},selection:{de:"die Reihenfolge ist der Eingang `waitlistOrder` des Wartelistenknotens (automatisches Nachr\xFCcken gibt es nicht mehr; Freigabe-Strategie und Stichtag las nichts)",en:"the order is the waitlist node's input `waitlistOrder` (automatic promotion is gone; release strategy and deadline were read by nothing)"},progressLayout:{de:"das Fortschrittslayout geh\xF6rt zum Workflow: den Block nach workflow.json `progressLayout` verschieben (ohne Workflow l\xF6schen)",en:"the progress layout belongs to the workflow: move the block to workflow.json `progressLayout` (without a workflow: delete it)"}};function df(e){return e===null||typeof e!="object"||Array.isArray(e)?["manifest: data must be an object"]:Object.keys(e).map(n=>{let t=fl[n];return t!==void 0?`manifest: \`${n}\` is no longer part of manifest.json (${t.en}). Delete the line.`:`manifest: unknown key \`${n}\` \u2014 manifest.json carries no key.`})}s(df,"manifestIssues");function dz(e){let n=[],t=e.buses;if(!Array.isArray(t))return n;let r=t.find(i=>!!i&&typeof i=="object"&&i.key==="process");if(!r||!Array.isArray(r.states))return n;for(let i of r.states){if(!i||typeof i!="object")continue;let o=i;if(o.terminal!==!0&&(!o.external||typeof o.external!="object")){let a=typeof o.id=="string"?o.id:"?";n.push(`progressLayout: progress state '${a}' is non-terminal but declares no 'external' block (applicant-facing copy) \u2014 resolveStatusPresentation would throw at runtime`)}}return n}s(dz,"validateProgressLayoutExternalCopy");function cI(e){if(e===null||typeof e!="object")return["progressLayout: the full layout object is required"];let n=e.buses;return!Array.isArray(n)||!n.some(t=>!!t&&typeof t=="object"&&t.key==="process")?["progressLayout: the layout must declare the `process` bus"]:dz(e)}s(cI,"progressLayoutIssues");var uI=new Set(["nodes","assignmentRules","channels","processStore","pricingRules","staffInputs"]);var cz=new Set(["sections","effects","outcomes","testScenarios","env","views"]),cf={id:{de:"der Schl\xFCssel des Formulars ist sein Slug",en:"the form's key is its slug"},label:{de:"der Name steht in der Formularzeile (createSmartForm.label)",en:"the name is the form row's (createSmartForm.label)"},outcomeIds:{de:"die Ergebnisse sind die ids von outcomes[]",en:"the outcomes are the ids of outcomes[]"},schoolSlug:{de:"von nichts gelesen",en:"read by nothing"}};function fI(e,n){if(e===null||typeof e!="object"||Array.isArray(e))return[{de:`${n}: die Formulardefinition muss ein Objekt sein.`,en:`${n}: the form definition must be an object.`}];let t=[];for(let i of Object.keys(e)){if(cz.has(i))continue;let o=cf[i];t.push(o!==void 0?{de:`${n}: \`${i}\` geh\xF6rt nicht mehr zur Formulardefinition (${o.de}). Die Zeile l\xF6schen.`,en:`${n}: \`${i}\` is no longer part of the form definition (${o.en}). Delete the line.`}:{de:`${n}: unbekannter Schl\xFCssel \`${i}\`.`,en:`${n}: unknown key \`${i}\`.`})}let r=e;for(let i of["sections","effects","outcomes"])Array.isArray(r[i])||t.push({de:`${n}: \`${i}\` muss eine Liste sein.`,en:`${n}: \`${i}\` must be a list.`});return t}s(fI,"smartFormDefinitionShapeIssues");var bt=["granted","rejected","waitlisted","other"];function Ii(e){return typeof e=="string"&&bt.includes(e)}s(Ii,"isOutcomeSemantic");var Yt=["arrival","manual"],pI={arrival:{de:"Nach Eingang",en:"By arrival"},manual:{de:"Von Hand sortiert",en:"Sorted by hand"}};function uz(e,n){let t=e.inputs?.[n];return t?.kind==="literal"?t.value:void 0}s(uz,"literal");function ay(e){let n=uz(e,"waitlistOrder");return Yt.includes(n)?{waitlistOrder:n}:null}s(ay,"waitlistPolicyOrNull");var wn="responsible",ly="team:";function uf(e){return`${ly}${e}`}s(uf,"teamSlot");function ff(e){return e.startsWith(ly)?e.slice(ly.length):null}s(ff,"teamKeyOfSlot");function mI(e){return e.kind==="responsible"?wn:uf(e.groupKey)}s(mI,"slotIdOf");function pf(e){if(e===wn)return{kind:"responsible"};let n=ff(e);return n===null||n.length===0?null:{kind:"team",groupKey:n}}s(pf,"slotOfId");var dy="review",cy="checkField",hI="reviewed",gI="reviewing",mf=["rejected","waitlisted"];function uy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(uy,"isObject");var fz=new Set(["decision",dy]),yI={approved:"granted",accepted:"granted",admitted:"granted",direkt:"granted",rejected:"rejected",absage:"rejected",declined:"rejected",waitlisted:"waitlisted",warteliste:"waitlisted"};function fy(e){return Object.hasOwn(yI,e)?yI[e]:void 0}s(fy,"legacySemanticOfId");function pz(e){return e===dy?bt.filter(n=>!mf.includes(n)):bt}s(pz,"allowedSemanticsFor");var mz="other";function wI(e){return uy(e)&&fz.has(String(e.type))&&Array.isArray(e.outcomes)?e.outcomes:[]}s(wI,"outcomesOf");function kI(e){return(e?.nodes??[]).some(n=>wI(n).some(t=>uy(t)&&!("semantic"in t)))}s(kI,"needsOutcomeSemantics");function bI(e,n={}){let t=[],r=[],i=[],o=e.nodes.map(a=>{let l=wI(a);if(l.length===0)return a;let d=a,c=String(d.id),u=String(d.type),p=pz(u),m=!1,y=l.map(k=>{if(!uy(k))return k;let g=String(k.id);if("semantic"in k)return Ii(k.semantic)||i.push({nodeId:c,outcomeId:g,value:String(k.semantic)}),k;let v=`${c}.${g}`,E=Object.hasOwn(n,v)?n[v]:void 0;if(E!==void 0)return p.includes(E)?(t.push({nodeId:c,outcomeId:g,semantic:E,source:"answer"}),m=!0,{...k,semantic:E}):(r.push({nodeId:c,nodeType:u,outcomeId:g,allowed:p,answer:E}),k);let A=fy(g),I=A??mz;return p.includes(I)?(t.push({nodeId:c,outcomeId:g,semantic:I,source:A===void 0?"formerDefault":"legacyTable"}),m=!0,{...k,semantic:I}):(r.push({nodeId:c,nodeType:u,outcomeId:g,allowed:p}),k)});return m?{...d,outcomes:y}:a});return t.length===0?{graph:e,written:t,refused:r,invalid:i}:{graph:{...e,nodes:o},written:t,refused:r,invalid:i}}s(bI,"addOutcomeSemantics");var mr="bewerbungOffen";function go(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(go,"isObject");var py=["event","effect"];function vI(e){return go(e)&&e.type==="eventTrigger"}s(vI,"isTrigger");function xI(e){let n=go(e.inputs)?e.inputs:{};return"outcomes"in e||py.some(t=>t in e||t in n)}s(xI,"oldShape");function SI(e){return(e?.nodes??[]).some(n=>vI(n)&&xI(n))}s(SI,"needsEventTriggerStartMove");function hz(e){let n=String(e.id),r=(Array.isArray(e.outcomes)?e.outcomes:[]).map(l=>go(l)?l.id:void 0);if("outcomes"in e&&!(r.length===1&&r[0]===mr))return{unmoved:{nodeId:n,reason:"outcomesNotStart"}};let i=Object.keys(go(e.next)?e.next:{});if(!(i.length===1&&i[0]===mr))return{unmoved:{nodeId:n,reason:"nextNotStart"}};let o=go(e.inputs)?{...e.inputs}:{};for(let l of py){let d=o[l];if(go(d)&&d.kind==="binding")return{unmoved:{nodeId:n,reason:"bindingCell"}}}let a={...e};delete a.outcomes;for(let l of py)delete a[l],delete o[l];return go(e.inputs)&&(Object.keys(o).length>0?a.inputs=o:delete a.inputs),{node:a}}s(hz,"moveNode");function AI(e){let n=[],t=[],r=e.nodes.map(i=>{if(!vI(i)||!xI(i))return i;let o=hz(i);return"unmoved"in o?(t.push(o.unmoved),i):(n.push(String(i.id)),o.node)});return n.length===0?{graph:e,moved:n,unmoved:t}:{graph:{...e,nodes:r},moved:n,unmoved:t}}s(AI,"moveEventTriggerStart");function pl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(pl,"isObject");var EI={waitlistOrder:"arrival"};function TI(e){return!pl(e)||e.type!=="waitlist"?!1:!("waitlistOrder"in(pl(e.inputs)?e.inputs:{}))}s(TI,"lacksPolicy");function gz(e){return(e?.nodes??[]).some(TI)}s(gz,"needsWaitlistPolicyMove");function my(e){return pl(e)&&Yt.includes(e.waitlistOrder)}s(my,"isWaitlistPolicy");function yz(e){if(e===void 0)return{policy:EI,stated:!1};if(!pl(e))return"malformed";let n=e.waitlistOrder;return n!==void 0&&!Yt.includes(n)?"malformed":{policy:{waitlistOrder:n??EI.waitlistOrder},stated:n!==void 0}}s(yz,"policyOfSelection");function $I(e,n,t={}){let r=[],i=[];if(!gz(e))return{graph:e,moved:r,refused:i};let o=yz(n),a=e.nodes.map(l=>{if(!TI(l))return l;let d=l,c=String(d.id),u=pl(d.inputs)?{...d.inputs}:{},p=Object.hasOwn(t,c)?t[c]:void 0,m,y;if(p!==void 0)m=p,y="answer";else{if(o==="malformed")return i.push({nodeId:c,reason:"selectionMalformed"}),l;m=o.policy,y=o.stated?"manifest":"formerDefault"}return u.waitlistOrder={kind:"literal",value:m.waitlistOrder},r.push({nodeId:c,policy:m,source:y}),{...d,inputs:u}});return r.length===0?{graph:e,moved:r,refused:i}:{graph:{...e,nodes:a},moved:r,refused:i}}s($I,"moveWaitlistPolicyToInputs");function yo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(yo,"isObject");var wz=[Vn,ho],kz=["inputSchema","parties","schemaDigest","parts"];function RI(e){return yo(e)&&e.type==="governedDocument"&&("resolver"in e||yo(e.template)&&("key"in e.template||"cockpitFields"in e.template))}s(RI,"oldShape");function II(e){return(e?.nodes??[]).some(RI)}s(II,"needsGeneratorInputMove");function bz(e){let n=yo(e.inputs)?{...e.inputs}:{},t={...e},r;if("resolver"in e){let i=e.resolver;if(!yo(i))return{unmoved:"resolverNotObject"};if(Vn in n)return{unmoved:"generatorInputExists"};if(typeof i.key!="string"||i.key.length===0)return{unmoved:"pinWithoutKey"};if(i.kind!=="generator"&&i.kind!=="package")return{unmoved:"pinWithoutKind"};if(i.revision!==void 0&&!(typeof i.revision=="number"&&Number.isInteger(i.revision)&&i.revision>0))return{unmoved:"pinRevisionInvalid"};if((yo(i.inputSchema)&&Array.isArray(i.inputSchema.fields)?i.inputSchema.fields:[]).find(d=>yo(d)&&wz.includes(String(d.key)))!==void 0)return{unmoved:"stampDeclaresReservedKey"};n[Vn]={kind:"literal",value:{kind:i.kind,key:i.key,...i.revision===void 0?{}:{revision:i.revision}}};let l=Object.fromEntries(kz.filter(d=>d in i).map(d=>[d,i[d]]));Object.keys(l).length>0&&(t.generatorStamp=l),r=i.cockpitFields,delete t.resolver}if(yo(e.template)&&("key"in e.template||"cockpitFields"in e.template)){let{key:i,cockpitFields:o,...a}=e.template;if("key"in e.template){if(ho in n)return{unmoved:"templateInputExists"};if(typeof i!="string"||i.length===0)return{unmoved:"templateKeyInvalid"};n[ho]={kind:"literal",value:i}}if(o!==void 0){if(r!==void 0)return{unmoved:"cockpitFieldsTwice"};r=o}t.template=a}if(r!==void 0){if("cockpitFields"in e)return{unmoved:"cockpitFieldsExist"};t.cockpitFields=r}return t.inputs=n,{node:t}}s(bz,"moveNode");function OI(e){let n=[],t=[],r=e.nodes.map(i=>{if(!RI(i))return i;let o=bz(i);return"unmoved"in o?(t.push({nodeId:String(i.id),reason:o.unmoved}),i):(n.push(String(i.id)),o.node)});return n.length===0?{graph:e,moved:n,unmoved:t}:{graph:{...e,nodes:r},moved:n,unmoved:t}}s(OI,"moveGeneratorPinsToInputs");var PI=/^\d{4}-\d{2}-\d{2}$/;function hr(e,n){return{de:e,en:n}}s(hr,"issue");function wo(e){if(typeof e!="object"||e===null)return hr("keine Reduktion","not a reduction");let n=e;if(n.kind==="none")return Object.keys(n).length===1?null:hr('\u201Ekeine Reduktion" tr\xE4gt keine weiteren Angaben','"no reduction" carries no further details');if(n.kind!=="amount")return hr(`unbekannte Art ${JSON.stringify(n.kind)}`,`unknown kind ${JSON.stringify(n.kind)}`);let{amount:t,activeFrom:r,activeTo:i}=n;return typeof t!="number"||!Number.isFinite(t)||t<=0?hr("der Betrag muss gr\xF6\xDFer als 0 \u20AC sein","the amount must be greater than \u20AC0"):Number.isInteger(Number((t*100).toFixed(6)))?typeof r!="string"||!PI.test(r)?hr("der Beginn fehlt (JJJJ-MM-TT)","the start is missing (YYYY-MM-DD)"):typeof i!="string"||!PI.test(i)?hr("das Ende fehlt (JJJJ-MM-TT)","the end is missing (YYYY-MM-DD)"):i<r?hr("das Ende liegt vor dem Beginn","the end is before the start"):n.floorTotal!==void 0&&(typeof n.floorTotal!="number"||!Number.isSafeInteger(n.floorTotal)||n.floorTotal<0)?hr("die Untergrenze muss ein nichtnegativer Centbetrag sein","the floor must be a non-negative amount in cents"):n.pricePeriod!==void 0&&!["month","year","once","unit"].includes(String(n.pricePeriod))?hr("ung\xFCltige Preisperiode","invalid price period"):Object.keys(n).some(o=>!["kind","amount","activeFrom","activeTo","floorTotal","pricePeriod"].includes(o))?hr("unbekannte Angaben","unknown details"):null:hr("der Betrag hat mehr als zwei Nachkommastellen","the amount has more than two decimal places")}s(wo,"reductionShapeIssue");function Oi(e){if(typeof e!="object"||e===null)return!1;let n=e;return typeof n.itemKey=="string"&&n.itemKey.length>0&&Array.isArray(n.grantKeys)&&n.grantKeys.every(t=>typeof t=="string"&&t.length>0)&&(n.reduction===void 0||wo(n.reduction)===null&&n.reduction.kind==="amount")}s(Oi,"isPricedItemValue");var vs=["freetext","recommendation","choice","pricedItem","record","reduction"],xs=[...vs,"appointment"];function _I(e){return typeof e=="string"&&xs.includes(e)}s(_I,"isTaskResultKind");function Pi(e){return typeof e=="string"&&vs.includes(e)}s(Pi,"isRecordedTaskResultKind");function Ss(e){return Pi(e.kind)}s(Ss,"isRecordedTaskResult");var hf=["number","boolean","enum"];function hy(e){return typeof e=="string"&&hf.includes(e)}s(hy,"isRecordFieldType");var gy=["form","siblingRank"];var ti={freetext:{choiceValueType:null,valueType:null,textValueType:"string",label:{de:"Freitext",en:"Free text"}},recommendation:{choiceValueType:"enum",valueType:null,textValueType:"string",label:{de:"Empfehlung",en:"Recommendation"}},choice:{choiceValueType:"enum",valueType:"enum",textValueType:"string",label:{de:"Auswahl",en:"Choice"}},pricedItem:{choiceValueType:"enum",valueType:"pricedItem",textValueType:"string",label:{de:"Preisposition",en:"Priced item"}},reduction:{choiceValueType:null,valueType:"reduction",textValueType:"string",label:{de:"Reduktion",en:"Reduction"}},record:{choiceValueType:null,valueType:null,textValueType:"string",label:{de:"Erfassung",en:"Record"}},appointment:{choiceValueType:null,valueType:null,textValueType:null,label:{de:"Termin",en:"Appointment"}}};function CI(e){return(e.kind==="freetext"||e.kind==="recommendation"||e.kind==="choice")&&e.writes===void 0}s(CI,"isProseResult");function gf(e){return e.kind==="record"?(e.fields??[]).filter(n=>typeof n.writes=="string"&&n.writes.length>0&&hy(n.type)).map(n=>({key:n.writes,valueType:n.type,field:n})):vz(e)}s(gf,"draftResultStoreWrites");function vz(e){let n=ti[e.kind].valueType;return e.writes===void 0||n===null?[]:[{key:e.writes,valueType:n}]}s(vz,"singleStoreWrite");var NI="team:";function As(e){if(e==="all")return{kind:"all"};if(e==="external"||e.length===0)return null;if(e.startsWith(NI)){let n=e.slice(NI.length);return n.length===0?null:{kind:"team",groupKey:n}}return{kind:"channel",channelKey:e}}s(As,"parseTaskResultChat");var Ze={unknownKind:"[taskResult/unknownKind]",onApproval:"[taskResult/onApproval]",unknownField:"[taskResult/unknownField]",choiceOptions:"[taskResult/choiceOptions]",textRequiredOnFreetext:"[taskResult/textRequiredOnFreetext]",chatMissing:"[taskResult/chatMissing]",chatExternal:"[taskResult/chatExternal]",chatUnknownChannel:"[taskResult/chatUnknownChannel]",appointmentMissingTitle:"[taskResult/appointmentMissingTitle]",pricedItemMissingItem:"[taskResult/pricedItemMissingItem]",pricedItemUnknownItem:"[taskResult/pricedItemUnknownItem]",pricedItemNotInProgram:"[taskResult/pricedItemNotInProgram]",pricedItemOfferWithoutProgram:"[taskResult/pricedItemOfferWithoutProgram]",itemOnNonPricedItem:"[taskResult/itemOnNonPricedItem]",writesOnProse:"[taskResult/writesOnProse]",labelMissing:"[taskResult/labelMissing]",appointmentInvalidDuration:"[taskResult/appointmentInvalidDuration]",recordFields:"[taskResult/recordFields]",fieldsOnNonRecord:"[taskResult/fieldsOnNonRecord]",recordSuggest:"[taskResult/recordSuggest]",reductionPrices:"[taskResult/reductionPrices]",pricesOnNonReduction:"[taskResult/pricesOnNonReduction]"};var xz=new Set(["if","else","in","true","false","null"]),Sz=new Set(["==","!=","<=",">=","&&","||"]);function Az(e){return e>="0"&&e<="9"}s(Az,"isDigit");function Ez(e){return/[a-zA-Z_$]/.test(e)}s(Ez,"isIdentStart");function Tz(e){return/[a-zA-Z0-9_.$]/.test(e)}s(Tz,"isIdentCont");function $z(e){let n=[],t=0;for(;t<e.length;){let r=e.charAt(t);if(r===" "||r===" "||r===`
|
|
10944
|
+
`};var Qu="a1c7c27a03477d01d2d63d91189b501efe4478531191c698880833753e2130db",Ug=PR;var Gg=class extends xe{static{s(this,"AgentToolsCommand")}static paths=[["agent","tools"]];static usage=$.Usage({category:"Agents",description:"Show the shared platform/CLI agent tool schemas and skill revision."});async execute(){return this.print({skillHash:Qu,tools:ll}),0}},zg=class extends xe{static{s(this,"AgentInvokeCommand")}static paths=[["agent","invoke"]];static usage=$.Usage({category:"Agents",description:"Invoke a shared agent tool; pipe its JSON input on stdin."});tool=f.String("--tool",{required:!0,description:"plexus|plexus_skill|plexus_workspace"});async execute(){if("isTTY"in this.context.stdin&&this.context.stdin.isTTY===!0)throw new Error("plexus: pipe the tool's JSON input on stdin.");let n=JSON.parse(await Vg(this.context.stdin)),t=await this.context.executePlexusAgentTool(this.tool,n);return this.print(t),0}},NR=[Gg,zg];var Wg=[{key:"fixture_test",email:"test@example.com",firstName:"Test",lastName:"Bewerber"}],Eae=new Set(Wg.map(e=>e.key));function CR(e,n,t,r){let i=e.flatMap(l=>l.angebote).find(l=>l.offerKey===n);if(i===void 0){let l=e.flatMap(d=>d.angebote.map(c=>c.offerKey));throw new Error(`applications start-test: no offer "${n}" (offers: ${l.join(", ")||"none"})`)}let o=i.stages.find(l=>l.stageKey===r||l.stageId===r);if(o===void 0){let l=i.stages.map(d=>`${d.stageKey} (${d.stageId})`);throw new Error(`applications start-test: no level "${r}" in ${n} \u2014 name it by key or id: ${l.join(", ")}`)}let a=o.runs.find(l=>l.runKey===t||l.runId===t);if(a===void 0){let l=o.runs.map(d=>`${d.runKey} (${d.runId})`);throw new Error(`applications start-test: no school year "${t}" for level ${o.stageKey} \u2014 name it by key or id: ${l.join(", ")}`)}if(!a.isOpen)throw new Error(`applications start-test: school year ${a.runKey} is closed for level ${o.stageKey}`);return{programRunId:a.runId,programStageId:o.stageId}}s(CR,"resolveStartTarget");function JG(e){return e.kind==="named"?e.name:`(${e.standIn??e.fallback})`}s(JG,"applicantText");function DR(e){return e.map(n=>({id:n.application._id,status:n.deletedAt?`${n.application.status} (gel\xF6scht)`:n.application.status,state:n.currentProcessStateId??"",applicant:JG(n.applicantName),test:n.application.testMode===!0?"test":""}))}s(DR,"applicationRows");var _R=Wg.map(e=>e.email);function FR(e,n,t,r){if(t===void 0&&r===void 0)throw new Error("applications start-test: name the applicant \u2014 --party <partyId> or --applicant <email>");if(t!==void 0&&r!==void 0)throw new Error("applications start-test: --party or --applicant, not both");if(Kg(e,n)&&(r===void 0||!_R.includes(r.trim().toLowerCase())))throw new Error(`applications start-test: on prod only for the test account ${_R.join(", ")} (--applicant) \u2014 never a real family's`)}s(FR,"assertStartApplicant");function LR(e){let n={};for(let{address:t,...r}of e.entries)n[t]=r;return{applicationId:e.applicationId,store:n}}s(LR,"processStoreJson");function QG(e){switch(e.kind){case"form":return`form ${e.formInstanceId} (${e.state})`;case"document":return e.file===null?`document ${e.slotKey} (leer)`:`document ${e.slotKey} \xB7 v${e.file.versionNumber} ${e.file.filename??e.file.artifactId}`;case"contract":return`contract ${e.contractId} \xB7 ${e.revision===null?"keine Fassung":`Fassung ${e.revision.revisionNumber}`} \xB7 ${e.contractStatus}`;case"contracts":return e.contracts.map(n=>`${n.partKey}: contract ${n.contractId} \xB7 ${n.revision===null?"keine Fassung":`Fassung ${n.revision.revisionNumber}`} \xB7 ${n.contractStatus}`).join("; ")}}s(QG,"refText");function ZG(e){return e.state!=="present"?e.reason?.de??"":e.ref!==void 0?QG(e.ref):JSON.stringify(e.value)}s(ZG,"holds");function MR(e){return e.entries.map(n=>({address:n.address,state:n.state,holds:ZG(n),producer:n.producer?.label??"",written:n.writtenAt===void 0?"":new Date(n.writtenAt).toISOString()}))}s(MR,"storeRows");function Zu(e){let n={},t={};for(let r of e){let i=r.indexOf("=");if(i<=0)throw new Error(`Expected key=value, got '${r}'.`);let o=r.slice(0,i);if(Object.hasOwn(t,o))throw new Error(`'${o}' is given twice.`);let a=r.slice(i+1);t[o]=a;try{n[o]=JSON.parse(a)}catch{n[o]=a}}return{values:n,raw:t}}s(Zu,"parseKv");var qR="started",Xu="submitted",ef="submitted",KR="load-scenario:";var jR="(Bewerbung)";function BR(e){return{nodeId:jR,actions:e.map(n=>({id:n.id,label:{de:`${n.label??n.id}${n.count===void 0?"":` (${n.count})`}`,en:`${n.label??n.id}${n.count===void 0?"":` (${n.count})`}`},...n.disabledReason===void 0?{}:{disabledReason:n.disabledReason}}))}}s(BR,"sharedAsList");function VR(e){return e.disabledReason===void 0?"":e.disabledCount===void 0?e.disabledReason:`${e.disabledReason} (${e.disabledCount})`}s(VR,"disabledText");function UR(e){return e.flatMap(({nodeId:n,actions:t})=>t.map(r=>({node:n,action:r.id,label:r.label.de,disabled:VR(r)})))}s(UR,"actionRows");function GR(e,n,t=[]){let r=e.filter(({actions:d})=>d.some(c=>c.id===n));if(r.length===0){let d=[...new Set(e.flatMap(({actions:c})=>c.map(u=>u.id)))];throw new Error(`test-actions run: no current node offers "${n}" (offered: ${d.join(", ")||"nothing"})`)}if(r.length>1)throw new Error(`test-actions run: "${n}" is offered by ${r.map(d=>d.nodeId).join(", ")} \u2014 pass --node`);let{nodeId:i,actions:o}=r[0],a=o.find(d=>d.id===n);if(a.disabledReason!==void 0)throw new Error(`test-actions run: "${n}" on ${i} is disabled: ${VR(a)}`);if(i!==jR)return i;let l=t[0];if(l===void 0)throw new Error(`test-actions run: "${n}" needs a current node \u2014 the application has none`);return l}s(GR,"nodeOfferingAction");function zR(e,n,t){if(e.startsWith(KR)){if(Object.hasOwn(t,"autoSubmit"))throw new Error(`test-actions run: ${e}: a scenario's autoSubmit is set by --auto-submit / --no-auto-submit, not --param`);return{autoSubmit:n,...t}}return Object.keys(t).length===0?void 0:{...t}}s(zR,"runParams");async function XG(e,n){let t=await e.query(x.workflow.getInstance,{applicationId:n});if(t===null)throw new Error(`test-actions: application ${n} has no workflow instance`);return t.instance.currentNodeIds}s(XG,"currentNodeIds");function ez(e,n){switch(n){case"notTestApplication":return`${e} is not a test application`;case"completed":case"aborted":case"deleted":return`${e} is ${n} \u2014 test actions run only on an active application`;case"missingPermission":return"the caller lacks bewerbungsmanagement.testActions.run"}}s(ez,"refusalText");async function nf(e,n,t){let r=await e.query(x.workflow.listSharedTestActions,{applicationId:n});if(!r.permitted)throw new Error(`test-actions: not permitted \u2014 ${ez(n,r.reason)}`);let i=[];for(let o of t){let a=await e.query(x.workflow.listTestActions,{applicationId:n,nodeId:o});if(a===null)throw new Error(`test-actions: node "${o}" is not in this application's workflow (or it has no instance)`);i.push({nodeId:o,actions:a})}return[...i,BR(r.actions)]}s(nf,"actionsOf");async function WR(e,n,t){return t!==void 0?[t]:await XG(e,n)}s(WR,"nodesOf");var Yg=class extends D{static{s(this,"TestActionsListCommand")}static paths=[["test-actions","list"]];static usage=$.Usage({category:"Admission",description:"List the test-mode actions of the application's current node(s) (scenarios, auto-fill-files, submit, \u2026) and the application-wide ones"});application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});async execute(){let n=await this.caller(),t=await nf(n,this.application,await WR(n,this.application,this.node));return this.print(t,UR,["node","action","label","disabled"]),0}},Hg=class extends D{static{s(this,"TestActionsRunCommand")}application=f.String("--application",{required:!0,description:"Application id (a test application)"});node=f.String("--node",{description:"Node id (default: the application's current nodes)"});static paths=[["test-actions","run"]];static usage=$.Usage({category:"Admission",description:"Run one test-mode action; a scenario (load-scenario:<id>) also submits unless --no-auto-submit"});action=f.String("--action",{required:!0,description:"Action id, e.g. load-scenario:standard, auto-fill-files, submit-form"});autoSubmit=f.Boolean("--auto-submit",!0,{description:"Scenario only: stub the file fields and submit after loading (default on; --no-auto-submit only loads)"});param=f.Array("--param",{description:"Action parameter key=value (repeatable; the value is JSON where it parses, else text), e.g. --param confirmed=true for an action that asks a question first (its `confirm` in `test-actions list`)"});async execute(){let n=zR(this.action,this.autoSubmit,Zu(this.param??[]).values),t=await this.caller(),r=this.application,i=await WR(t,this.application,this.node),o=GR(await nf(t,r,i),this.action,i);return await t.mutation(x.workflow.runTestAction,{applicationId:r,nodeId:o,actionId:this.action,...n===void 0?{}:{params:n}}),this.print({ran:this.action,on:o},a=>[{key:"ran",value:a.ran},{key:"on",value:a.on},{key:"next",value:"test-actions list \u2014 file fills and the submit after them run asynchronously"}]),0}},YR=[Yg,Hg];var We=["de","en"];function hs(e,n){return We.every(t=>e[t]===n[t])}s(hs,"sameText");function Rn(e){if(e===null||typeof e!="object"||Array.isArray(e))return"not-localized";let n=e;return Object.keys(n).some(r=>!We.includes(r))?"not-localized":We.filter(r=>{let i=n[r];return typeof i!="string"||i.trim()===""})}s(Rn,"missingLocales");function $i(e){let n=Rn(e);return n!=="not-localized"&&n.length===0}s($i,"isLocalizedText");function dl(e,n){let t={};for(let r of We){let i=e.map(o=>o[r]);t[r]=i.every(o=>typeof o=="string"&&o.trim()!=="")?n(i,r):""}return t}s(dl,"composeTexts");var fr=/^[a-z][A-Za-z0-9]*$/;function Jg(e){return typeof e=="string"&&fr.test(e)}s(Jg,"isNodeId");function gs(e,n){Jg(e)||F(`[graph/nodeIdFormat] "${e}" cannot name a node: a node id is ${fr.source}.`);let t=new Set(n);if(!t.has(e))return e;let r=2;for(;t.has(`${e}${r}`);)r++;return`${e}${r}`}s(gs,"makeNodeId");var Ri="$env";function se(e){if(e.scope==="env")return`${Ri}.${e.key}`;let n=e.scope==="derived"?`$derived.${e.key}`:`$${e.scope}.${e.owner}.${e.key}`;return e.path===void 0?n:`${n}.${e.path}`}s(se,"formatAddress");var Cr=/^[a-z][a-zA-Z0-9_]*$/,nz=/^[A-Za-z_][A-Za-z0-9_]*$/;function po(e){return typeof e=="string"&&e.split(".").every(n=>nz.test(n))}s(po,"isPath");function Zr(e){if(!e.startsWith("$"))return null;let n=e.slice(1).split("."),[t,...r]=n;switch(t){case"env":{let i=r.join(".");return r.length>0&&po(i)?{scope:"env",key:i}:null}case"derived":{let[i,...o]=r;return i===void 0||!Cr.test(i)?null:HR({scope:"derived",key:i},o)}case"node":case"task":{let[i,o,...a]=r;return i===void 0||o===void 0||!Cr.test(o)||(t==="node"?!fr.test(i):!Cr.test(i))?null:HR({scope:t,owner:i,key:o},a)}default:return null}}s(Zr,"tryParseAddress");function HR(e,n){if(n.length===0)return e;let t=n.join(".");return po(t)?{...e,path:t}:null}s(HR,"withPath");function we(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let n=e,t=n.scope==="env"?["scope","key"]:n.scope==="derived"?["scope","key","path"]:["scope","owner","key","path"];if(Object.keys(n).some(r=>!t.includes(r))||n.path!==void 0&&!po(n.path))return!1;switch(n.scope){case"env":return po(n.key);case"derived":return typeof n.key=="string"&&Cr.test(n.key);case"node":return typeof n.owner=="string"&&fr.test(n.owner)&&typeof n.key=="string"&&Cr.test(n.key);case"task":return typeof n.owner=="string"&&Cr.test(n.owner)&&typeof n.key=="string"&&Cr.test(n.key);default:return!1}}s(we,"isAddress");var Xr={offer:{key:"string",title:"string"},unit:{key:"string",name:"string"},stage:{key:"string",name:"string",gradeLevel:"number"},run:{key:"string",name:"string",startDate:"date"},applicant:{language:"enum",channel:"enum"}},ys=Object.keys(Xr);function ws(e){return Object.hasOwn(Xr,e)}s(ws,"isEnvKey");var tz=["self-service","staff"];function JR(e,n){return{kind:"fixed",values:e,labels:n}}s(JR,"fixedSet");var tf={of:"applicant.language",withoutValue:"de"},ei={"offer.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Angebot",en:"Offer"}},"offer.title":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Titel des Angebots",en:"Offer title"},nameLanguage:tf},"unit.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Einheit",en:"Unit"}},"unit.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Einheit",en:"Unit name"},nameLanguage:tf},"stage.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Klassenstufe (Schl\xFCssel)",en:"Grade (key)"},cohortBound:!0},"stage.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Klassenstufe",en:"Grade name"},cohortBound:!0,nameLanguage:tf},"stage.gradeLevel":{valueSet:{kind:"open"},nullable:!0,absent:{de:"Die Stufe hat keine Klassenstufe (Kindergarten).",en:"The stage has no grade level (Kindergarten)."},label:{de:"Klassenstufe",en:"Grade level"},cohortBound:!0},"run.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Schuljahr",en:"School year"},cohortBound:!0},"run.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name des Schuljahrs",en:"School year name"},cohortBound:!0,nameLanguage:tf},"run.startDate":{valueSet:{kind:"open"},nullable:!0,absent:{de:"F\xFCr das Schuljahr ist kein Beginn erfasst.",en:"The school year has no start date."},label:{de:"Beginn des Schuljahrs",en:"School year start"},cohortBound:!0},"applicant.language":{valueSet:JR(We,{de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}}),nullable:!0,absent:{de:"Die Bewerbung hat kein Bewerberkonto (intern angelegt).",en:"The application has no applicant account (started by staff)."},label:{de:"Bewerbersprache",en:"Applicant language"}},"applicant.channel":{valueSet:JR(tz,{staff:{de:"intern",en:"in-house"},"self-service":{de:"online (Familie)",en:"online (family)"}}),nullable:!1,label:{de:"Eingangsweg",en:"Intake channel"}}},rf={types:Xr,fields:ei},of=ys.flatMap(e=>Object.keys(Xr[e]).map(n=>`${e}.${n}`));function Wt(e){return Object.hasOwn(ei,e)}s(Wt,"isEnvLeaf");function sf(e){return`${Ri}.${e}`}s(sf,"envIdentifier");function mo(e){let n=ei[e],[t,r]=e.split("."),i=Xr[t][r];i===void 0&&F(`[env] leaf "${e}" has no type`);let o=n.valueSet;return{leaf:e,type:i,label:n.label,nullable:n.nullable,...n.absent===void 0?{}:{absent:n.absent},...n.nameLanguage===void 0?{}:{nameLanguage:n.nameLanguage},...n.cohortBound===void 0?{}:{cohortBound:n.cohortBound},...o.kind==="fixed"?{enumOptions:o.values.map(a=>{let l=o.labels[a];return l===void 0&&F(`[env] "${e}" names the value "${a}" without a label`),{value:a,label:l}})}:{}}}s(mo,"envLeaf");var QR="staffInput";var rz=["boolean"],cl=/^[a-z][A-Za-z0-9]*$/;function af(e){return e.staffInputs??[]}s(af,"staffInputsOf");function lf(e){return`${QR}.${e}`}s(lf,"staffInputLeaf");function ZR(e){return`${Ri}.${lf(e)}`}s(ZR,"staffInputIdentifier");function iz(e){let n=`${QR}.`;return e.startsWith(n)?e.slice(n.length):null}s(iz,"staffInputKeyOfLeaf");function ks(e,n){let t=iz(n);return t===null?void 0:af(e).find(r=>r.key===t)}s(ks,"declaredStaffInput");function XR(e){return[...af(e).map(n=>({leaf:lf(n.key),type:n.type,label:n.label,valueSet:{kind:"open"},nullable:!1,cohortBound:!1})),...of.map(n=>{let t=mo(n);return{leaf:n,type:t.type,label:t.label,valueSet:ei[n].valueSet,nullable:t.nullable,cohortBound:t.cohortBound===!0}})]}s(XR,"envLeavesFor");function eI(e){return XR(e).filter(n=>!n.cohortBound)}s(eI,"conditionEnvLeaves");function nI(e){return rI(eI(e))}s(nI,"envConditionSchemaFor");function oz(e){return XR(e).map(n=>n.leaf==="stage.key"?{...n,valueSet:{kind:"open"}}:n)}s(oz,"offerConditionEnvLeaves");function tI(e){return rI(oz(e))}s(tI,"offerConditionSchemaFor");function rI(e){let n={},t={};for(let{leaf:r,type:i,valueSet:o,nullable:a}of e){let[l="",d=""]=r.split(".");n[l]={...n[l]??{},[d]:i},t[r]={valueSet:o,nullable:a}}return{types:n,fields:t}}s(rI,"schemaOfLeaves");function iI(e){let n=e.staffInputs;if(n===void 0)return[];if(!Array.isArray(n))return[{path:"staffInputs",reason:{de:"[staffInput/shape] graph.staffInputs muss eine Liste sein.",en:"[staffInput/shape] graph.staffInputs must be a list."}}];let t=[],r=new Set;return n.forEach((i,o)=>{let a=`staffInputs[${o}]`,l=i;if(l===null||typeof l!="object"||typeof l.key!="string"){t.push({path:a,reason:{de:"[staffInput/shape] Eine interne Angabe braucht key, type und label ({ de, en }).",en:"[staffInput/shape] An internal entry needs key, type and label ({ de, en })."}});return}let d={de:`Interne Angabe "${l.key}"`,en:`Internal entry "${l.key}"`};cl.test(l.key)||t.push({path:`${a}.key`,reason:{de:`[staffInput/keyFormat] ${d.de}: Schl\xFCssel beginnt mit einem Kleinbuchstaben und enth\xE4lt nur Buchstaben und Ziffern.`,en:`[staffInput/keyFormat] ${d.en}: the key starts with a lowercase letter and contains only letters and digits.`}}),r.has(l.key)&&t.push({path:`${a}.key`,reason:{de:`[staffInput/duplicateKey] ${d.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[staffInput/duplicateKey] ${d.en}: the key is used twice.`}}),r.add(l.key),rz.includes(l.type)||t.push({path:`${a}.type`,reason:{de:`[staffInput/unknownType] ${d.de}: Typ "${String(l.type)}" \u2014 erlaubt ist nur "boolean" (K\xE4stchen).`,en:`[staffInput/unknownType] ${d.en}: type "${String(l.type)}" \u2014 only "boolean" (checkbox) is allowed.`}});let c=Rn(l.label);c==="not-localized"?t.push({path:`${a}.label`,reason:{de:`[staffInput/shape] ${d.de}: label muss { de, en } sein.`,en:`[staffInput/shape] ${d.en}: label must be { de, en }.`}}):c.length>0&&t.push({path:`${a}.label`,reason:{de:`[i18n/missingTranslation] ${d.de}: Beschriftung fehlt in ${c.join(", ")}.`,en:`[i18n/missingTranslation] ${d.en}: label is missing in ${c.join(", ")}.`}})}),t}s(iI,"staffInputIssues");var sy={required:!0,description:"Offer slug (its offerKey)"},Qg=class extends D{static{s(this,"ApplicationsListCommand")}static paths=[["applications","list"]];static usage=$.Usage({category:"Admission",description:"List an offer's applications (id, status, board state, applicant, test)"});offer=f.String("--offer",sy);testOnly=f.Boolean("--test-only",!1,{description:"Only test applications"});async execute(){let n=await this.caller(),t=await n.query(x.admission.listForAngebot,{client:this.requireTenant(n),offerKey:this.offer}),r=DR(t).filter(i=>!this.testOnly||i.test==="test");return this.print(r,i=>i,["id","status","state","applicant","test"]),0}},Zg=class extends D{static{s(this,"ApplicationsCountsCommand")}static paths=[["applications","counts"]];static usage=$.Usage({category:"Admission",description:"Count an offer's applications per list"});offer=f.String("--offer",sy);async execute(){let n=await this.caller(),t=await n.query(x.admission.getCountsByListForAngebot,{client:this.requireTenant(n),offerKey:this.offer});return this.print(t,r=>[...Object.entries(r.counts).map(([i,o])=>({list:i,count:String(o)})),{list:"total",count:String(r.total)}],["list","count"]),0}},Xg=class extends D{static{s(this,"ApplicationsShowCommand")}static paths=[["applications","show"]];static usage=$.Usage({category:"Admission",description:"One application: status, test flag, offer, current workflow nodes"});application=f.String({required:!0});async execute(){let n=await this.caller(),t=this.application,r=await n.query(x.admission.get,{applicationId:t});if(r===null)throw new Error(`applications show: no application ${t} (or not visible to you)`);let i=await n.query(x.workflow.getInstance,{applicationId:t});return this.print({application:r,currentNodes:i?.instance.currentNodeIds??[]},o=>[{key:"id",value:t},{key:"status",value:o.application.status},{key:"test",value:o.application.testMode?"ja":"nein"},{key:"offer",value:o.application.offerId},{key:"current nodes",value:o.currentNodes.join(", ")}]),0}},ey=class extends D{static{s(this,"ApplicationsStoreCommand")}static paths=[["applications","store"]];static usage=$.Usage({category:"Admission",description:"One application's process store: every address of its pinned graph, resolved (present / pending / absent)",details:"Staff only (applications.manage). --json prints one object keyed by the canonical address ($node\u2026, $task\u2026, $derived\u2026, $env\u2026). Values are shown whatever their audience \u2014 never hand the output to the family. Recipe: playbooks/applications/inspect-process-store.md."});application=f.String({required:!0});async execute(){let t=await(await this.caller()).query(x.processStoreView.get,{applicationId:this.application});return this.print(LR(t),()=>MR(t),["address","state","holds","producer","written"]),0}},ny=class extends D{static{s(this,"ApplicationsStartTestCommand")}static paths=[["applications","start-test"]];static usage=$.Usage({category:"Admission",description:"Start a TEST application for an applicant (school year and level by key or id) and show what test mode offers next",details:"Always test mode. --applicant names the account by its login address (on prod only the tenant's test account); --party names the applicant party directly. Without --version it runs on the live generation, like the cockpit."});offer=f.String("--offer",sy);run=f.String("--run",{required:!0,description:"School year: its key or id (never its name)"});stage=f.String("--stage",{required:!0,description:"Level: its key or id (never its name)"});party=f.String("--party",{description:"Applicant party id"});applicant=f.String("--applicant",{description:"Applicant account login address (e.g. the test account test@example.com)"});version=f.String("--version",{description:"Offer version id to test (default: the live generation)"});staffInput=f.Array("--staff-input",{description:"A staff input the offer declares, as key=true|false \u2014 repeat it once per input; a staff start must set every one"});proxy=f.Boolean("--proxy",{description:"Start in Stellvertretung (--proxy) or not (--no-proxy); left out, the tenant's default applies, as in the cockpit"});async execute(){let n=await this.caller();FR(this.resolvedTarget(),this.prodUrls(),this.party,this.applicant);let t=this.requireTenant(n),r=CR(await n.query(x.admission.listAdmissionTree,{client:t}),this.offer,this.run,this.stage),i=this.party;if(this.applicant!==void 0){let d=await n.query(x.applicants.partyByEmail,{client:t,email:this.applicant});if(d===null)throw new Error(`applications start-test: no applicant account ${this.applicant} at this school (create it in the cockpit first)`);i=d}let o=await n.mutation(x.admission.staffStartApplicationForParty,{client:t,offerKey:this.offer,partyId:i,programRunId:r.programRunId,programStageId:r.programStageId,...this.proxy===void 0?{}:{startInProxy:this.proxy},staffInputs:sI(this.staffInput??[]),testMode:!0,...this.version===void 0?{}:{offerVersionId:this.version}}),a,l;try{let d=await n.query(x.workflow.getInstance,{applicationId:o.applicationId});if(d===null)throw new Error("the started application has no workflow instance");a=d.instance.currentNodeIds,l=(await nf(n,o.applicationId,a)).flatMap(c=>c.actions.map(u=>u.id))}catch(d){throw new Error(`applications start-test: started ${o.applicationId}, but reading its state failed: ${d instanceof Error?d.message:String(d)}`,{cause:d})}return this.print({applicationId:o.applicationId,currentNodes:a,testActions:l},d=>[{key:"application",value:d.applicationId},{key:"current nodes",value:d.currentNodes.join(", ")},{key:"test actions",value:d.testActions.join(", ")},{key:"next",value:`test-actions run --application ${d.applicationId} --action <id>`}]),0}},ty=class extends D{static{s(this,"ApplicationsDiscardTestCommand")}static paths=[["applications","discard-test"]];static usage=$.Usage({category:"Admission",description:"Discard a TEST application (the server refuses a real one), or with --all-test every expired one of the school",details:"With an id: discards that test application. With --all-test --older-than <N>d: lists the school's test applications whose last activity is older than N days (N \u2265 14) and that are not kept as a demo \u2014 a dry run unless --confirm; --confirm discards each expired one the server re-checks, the rest are reported with the reason. Recipe: playbooks/applications/expire-test-applications.md.",examples:[["Dry run","plexus-cli --env prod --tenant <t> applications discard-test --all-test --older-than 14d --dry-run"],["Discard","plexus-cli --env prod --tenant <t> --allow-prod applications discard-test --all-test --older-than 14d --confirm"]]});application=f.String({required:!1});allTest=f.Boolean("--all-test",!1,{description:"Every expired test application of the school instead of one id"});olderThan=f.String("--older-than",{description:"With --all-test: days without activity, as <N>d (N \u2265 14)"});dryRun=f.Boolean("--dry-run",!1,{description:"With --all-test: list only (the default)"});confirm=f.Boolean("--confirm",!1,{description:"With --all-test: discard (else the dry run)"});async execute(){if(!this.allTest){if(this.application===void 0)throw new Error("applications discard-test: name an application id, or use --all-test --older-than <N>d");if(this.olderThan!==void 0||this.dryRun||this.confirm)throw new Error("applications discard-test: --older-than, --dry-run and --confirm belong to --all-test");return await(await this.caller()).mutation(x.admission.discardTest,{applicationId:this.application}),this.print({discarded:this.application},u=>[{key:"discarded",value:u.discarded}]),0}if(this.application!==void 0)throw new Error("applications discard-test: --all-test takes no application id");if(this.olderThan===void 0)throw new Error("applications discard-test --all-test: --older-than <N>d is required");if(this.dryRun&&this.confirm)throw new Error("applications discard-test: --dry-run and --confirm exclude each other");let n=sz(this.olderThan),t=await this.caller(),r=this.requireTenant(t),i=[],o=null;for(;;){let c=await t.query(x.admission.testTtlPlan,{client:r,olderThanDays:n,cursor:o});if(i.push(...c.rows),c.isDone)break;o=c.continueCursor}let a=i.map(c=>({...c,result:c.verdict!=="expired"?"kept":c.block!==null?"blocked":this.confirm?"pending":"would discard"})),l=i.filter(c=>c.verdict==="expired"&&c.protectedDemo).map(c=>c.applicationId);if(this.confirm&&l.length>0)throw new Error(`applications discard-test --all-test: protected demo application(s) in the discard set, nothing discarded: ${l.join(", ")}`);let d=0;if(this.confirm)for(let c of a.filter(u=>u.result==="pending"))try{await t.mutation(x.admission.discardExpiredTest,{applicationId:c.applicationId,olderThanDays:n}),c.result="discarded"}catch(u){d++,c.result=`failed: ${u instanceof Error?u.message:String(u)}`}return this.print({olderThanDays:n,confirm:this.confirm,rows:a},c=>c.rows.map(u=>({id:u.applicationId,lastActivity:new Date(u.lastActivityAt).toISOString().slice(0,10),verdict:u.verdict,block:u.block??"",result:u.result})),["id","lastActivity","verdict","block","result"]),d>0?1:0}};function sz(e){let n=/^(\d+)d$/.exec(e.trim());if(n===null)throw new Error(`--older-than "${e}": expected <N>d, e.g. 14d`);return Number(n[1])}s(sz,"parseDays");var ry=class extends D{static{s(this,"ApplicationsSetKeepDemoCommand")}static paths=[["applications","set-keep-demo"]];static usage=$.Usage({category:"Admission",description:"Mark a TEST application \u201EDemo behalten\u201C (never expires, never discarded), or clear the mark with --off"});application=f.String({required:!0});off=f.Boolean("--off",!1,{description:"Clear the mark"});async execute(){return await(await this.caller()).mutation(x.admission.setKeepAsDemo,{applicationId:this.application,keep:!this.off}),this.print({application:this.application,keepAsDemo:!this.off},t=>[{key:"application",value:t.application},{key:"keep as demo",value:t.keepAsDemo?"ja":"nein"}]),0}},iy=class extends D{static{s(this,"ApplicationsStaffInputListCommand")}static paths=[["applications","staff-input","list"]];static usage=$.Usage({category:"Admission",description:"An application's internal inputs (set at the start): value, and why one can no longer be corrected"});application=f.String({required:!0});async execute(){let t=await(await this.caller()).query(x.admission.staffInputsOfApplication,{applicationId:this.application});return this.print(t,r=>r.map(i=>({key:i.key,label:i.label.de,value:String(i.value),correctable:i.block===null?"ja":i.block.de})),["key","label","value","correctable"]),0}},oy=class extends D{static{s(this,"ApplicationsStaffInputSetCommand")}static paths=[["applications","staff-input","set"]];static usage=$.Usage({category:"Admission",description:"Correct one internal input of an application, with a reason \u2014 refused once a node that reads it was entered",examples:[["Untick \u201EKind von Mitarbeitenden\u201C",'plexus-cli --env prod --tenant <t> --allow-prod applications staff-input set <id> --input staffApplication=false --reason "falsch angehakt"']]});application=f.String({required:!0});input=f.String("--input",{required:!0,description:"key=true|false"});reason=f.String("--reason",{required:!0,description:"Why \u2014 recorded on the application's activity feed"});async execute(){let n=await this.caller(),[{key:t,value:r}]=sI([this.input]);return await n.mutation(x.admission.correctStaffInput,{applicationId:this.application,key:t,value:r,reason:this.reason}),this.print({application:this.application,key:t,value:r},i=>[{key:"application",value:i.application},{key:i.key,value:String(i.value)}]),0}},oI=[Qg,Zg,Xg,ey,ny,ty,ry,iy,oy];function sI(e){return e.map(n=>{let[t="",r,...i]=n.split("=");if(!cl.test(t)||r!=="true"&&r!=="false"||i.length>0)throw new Error(`--staff-input "${n}": expected key=true or key=false`);return{key:t,value:r==="true"}})}s(sI,"parseStaffInputs");var Vn="contractGenerator",ho="documentTemplate";function ul(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let n=e,t=Object.keys(n);return(n.kind==="generator"||n.kind==="package")&&typeof n.key=="string"&&n.key.length>0&&(n.revision===void 0||typeof n.revision=="number"&&Number.isInteger(n.revision)&&n.revision>0)&&t.every(r=>r==="kind"||r==="key"||r==="revision")}s(ul,"isGeneratorRef");function aI(e,n){let t=e.inputs?.[n];return t?.kind==="literal"?t.value:void 0}s(aI,"literalOf");function ni(e){let n=aI(e,Vn);return ul(n)?n:null}s(ni,"generatorRefOfNode");function pr(e){let n=aI(e,ho);return typeof n=="string"&&n.length>0?n:null}s(pr,"documentTemplateKeyOfNode");function lI(e){return`${e.kind}:${e.key}${e.revision===void 0?"":`@${e.revision}`}`}s(lI,"generatorRefLabel");var az=["formExports","generatorStamp"];function dI(e,n,t){let r=e.inputs?.[Vn];(r?.kind!=="literal"||!ul(r.value))&&F(`applyGeneratorStamp: the node names no generator in inputs.${Vn} \u2014 a stamp derives from it`),t.freezeRevision&&n.revision!==void 0&&(e.inputs[Vn]={kind:"literal",value:{...r.value,revision:n.revision}}),e.generatorStamp={inputSchema:n.inputSchema,parties:n.parties,schemaDigest:n.schemaDigest,...n.parts===void 0?{}:{parts:n.parts}}}s(dI,"applyGeneratorStamp");var lz=["reads"];function bs(e){if(e===null||typeof e!="object")return e;let n={...e};return Array.isArray(n.nodes)&&(n.nodes=n.nodes.map(t=>{if(t===null||typeof t!="object")return t;let r={...t};for(let i of az)delete r[i];for(let i of lz)Array.isArray(r[i])&&r[i].length===0&&delete r[i];return r})),n}s(bs,"comparableWorkflowGraph");var fl={id:{de:"die Identit\xE4t ist der Slug des Angebots (bundle.yaml slugs.manifest)",en:"the identity is the offer's slug (bundle.yaml slugs.manifest)"},label:{de:"der Titel steht in bundle.yaml `label`",en:"the title is bundle.yaml `label`"},version:{de:"die Revision z\xE4hlt die Datenbank",en:"the database counts the revision"},applicantMode:{de:"von nichts gelesen",en:"read by nothing"},signatureLevel:{de:"von nichts gelesen",en:"read by nothing"},roleInstances:{de:"die Rollen kommen aus den Formular-Effekten",en:"roles come from the form effects"},leistungen:{de:"von nichts gelesen",en:"read by nothing"},capacity:{de:"die Kapazit\xE4t geh\xF6rt der Kohorte (program.runs[].capacities)",en:"capacity belongs to the cohort (program.runs[].capacities)"},progressLayoutId:{de:"von nichts gelesen",en:"read by nothing"},bewerbungsfenster:{de:"die Kohorte besitzt die \xD6ffnung (isOpen / applicationOpensAt)",en:"the cohort owns opening (isOpen / applicationOpensAt)"},selection:{de:"die Reihenfolge ist der Eingang `waitlistOrder` des Wartelistenknotens (automatisches Nachr\xFCcken gibt es nicht mehr; Freigabe-Strategie und Stichtag las nichts)",en:"the order is the waitlist node's input `waitlistOrder` (automatic promotion is gone; release strategy and deadline were read by nothing)"},progressLayout:{de:"das Fortschrittslayout geh\xF6rt zum Workflow: den Block nach workflow.json `progressLayout` verschieben (ohne Workflow l\xF6schen)",en:"the progress layout belongs to the workflow: move the block to workflow.json `progressLayout` (without a workflow: delete it)"}};function df(e){return e===null||typeof e!="object"||Array.isArray(e)?["manifest: data must be an object"]:Object.keys(e).map(n=>{let t=fl[n];return t!==void 0?`manifest: \`${n}\` is no longer part of manifest.json (${t.en}). Delete the line.`:`manifest: unknown key \`${n}\` \u2014 manifest.json carries no key.`})}s(df,"manifestIssues");function dz(e){let n=[],t=e.buses;if(!Array.isArray(t))return n;let r=t.find(i=>!!i&&typeof i=="object"&&i.key==="process");if(!r||!Array.isArray(r.states))return n;for(let i of r.states){if(!i||typeof i!="object")continue;let o=i;if(o.terminal!==!0&&(!o.external||typeof o.external!="object")){let a=typeof o.id=="string"?o.id:"?";n.push(`progressLayout: progress state '${a}' is non-terminal but declares no 'external' block (applicant-facing copy) \u2014 resolveStatusPresentation would throw at runtime`)}}return n}s(dz,"validateProgressLayoutExternalCopy");function cI(e){if(e===null||typeof e!="object")return["progressLayout: the full layout object is required"];let n=e.buses;return!Array.isArray(n)||!n.some(t=>!!t&&typeof t=="object"&&t.key==="process")?["progressLayout: the layout must declare the `process` bus"]:dz(e)}s(cI,"progressLayoutIssues");var uI=new Set(["nodes","assignmentRules","channels","processStore","pricingRules","staffInputs"]);var cz=new Set(["sections","effects","outcomes","testScenarios","env","views"]),cf={id:{de:"der Schl\xFCssel des Formulars ist sein Slug",en:"the form's key is its slug"},label:{de:"der Name steht in der Formularzeile (createSmartForm.label)",en:"the name is the form row's (createSmartForm.label)"},outcomeIds:{de:"die Ergebnisse sind die ids von outcomes[]",en:"the outcomes are the ids of outcomes[]"},schoolSlug:{de:"von nichts gelesen",en:"read by nothing"}};function fI(e,n){if(e===null||typeof e!="object"||Array.isArray(e))return[{de:`${n}: die Formulardefinition muss ein Objekt sein.`,en:`${n}: the form definition must be an object.`}];let t=[];for(let i of Object.keys(e)){if(cz.has(i))continue;let o=cf[i];t.push(o!==void 0?{de:`${n}: \`${i}\` geh\xF6rt nicht mehr zur Formulardefinition (${o.de}). Die Zeile l\xF6schen.`,en:`${n}: \`${i}\` is no longer part of the form definition (${o.en}). Delete the line.`}:{de:`${n}: unbekannter Schl\xFCssel \`${i}\`.`,en:`${n}: unknown key \`${i}\`.`})}let r=e;for(let i of["sections","effects","outcomes"])Array.isArray(r[i])||t.push({de:`${n}: \`${i}\` muss eine Liste sein.`,en:`${n}: \`${i}\` must be a list.`});return t}s(fI,"smartFormDefinitionShapeIssues");var bt=["granted","rejected","waitlisted","other"];function Ii(e){return typeof e=="string"&&bt.includes(e)}s(Ii,"isOutcomeSemantic");var Yt=["arrival","manual"],pI={arrival:{de:"Nach Eingang",en:"By arrival"},manual:{de:"Von Hand sortiert",en:"Sorted by hand"}};function uz(e,n){let t=e.inputs?.[n];return t?.kind==="literal"?t.value:void 0}s(uz,"literal");function ay(e){let n=uz(e,"waitlistOrder");return Yt.includes(n)?{waitlistOrder:n}:null}s(ay,"waitlistPolicyOrNull");var wn="responsible",ly="team:";function uf(e){return`${ly}${e}`}s(uf,"teamSlot");function ff(e){return e.startsWith(ly)?e.slice(ly.length):null}s(ff,"teamKeyOfSlot");function mI(e){return e.kind==="responsible"?wn:uf(e.groupKey)}s(mI,"slotIdOf");function pf(e){if(e===wn)return{kind:"responsible"};let n=ff(e);return n===null||n.length===0?null:{kind:"team",groupKey:n}}s(pf,"slotOfId");var dy="review",cy="checkField",hI="reviewed",gI="reviewing",mf=["rejected","waitlisted"];function uy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(uy,"isObject");var fz=new Set(["decision",dy]),yI={approved:"granted",accepted:"granted",admitted:"granted",direkt:"granted",rejected:"rejected",absage:"rejected",declined:"rejected",waitlisted:"waitlisted",warteliste:"waitlisted"};function fy(e){return Object.hasOwn(yI,e)?yI[e]:void 0}s(fy,"legacySemanticOfId");function pz(e){return e===dy?bt.filter(n=>!mf.includes(n)):bt}s(pz,"allowedSemanticsFor");var mz="other";function wI(e){return uy(e)&&fz.has(String(e.type))&&Array.isArray(e.outcomes)?e.outcomes:[]}s(wI,"outcomesOf");function kI(e){return(e?.nodes??[]).some(n=>wI(n).some(t=>uy(t)&&!("semantic"in t)))}s(kI,"needsOutcomeSemantics");function bI(e,n={}){let t=[],r=[],i=[],o=e.nodes.map(a=>{let l=wI(a);if(l.length===0)return a;let d=a,c=String(d.id),u=String(d.type),p=pz(u),m=!1,y=l.map(k=>{if(!uy(k))return k;let g=String(k.id);if("semantic"in k)return Ii(k.semantic)||i.push({nodeId:c,outcomeId:g,value:String(k.semantic)}),k;let v=`${c}.${g}`,E=Object.hasOwn(n,v)?n[v]:void 0;if(E!==void 0)return p.includes(E)?(t.push({nodeId:c,outcomeId:g,semantic:E,source:"answer"}),m=!0,{...k,semantic:E}):(r.push({nodeId:c,nodeType:u,outcomeId:g,allowed:p,answer:E}),k);let A=fy(g),I=A??mz;return p.includes(I)?(t.push({nodeId:c,outcomeId:g,semantic:I,source:A===void 0?"formerDefault":"legacyTable"}),m=!0,{...k,semantic:I}):(r.push({nodeId:c,nodeType:u,outcomeId:g,allowed:p}),k)});return m?{...d,outcomes:y}:a});return t.length===0?{graph:e,written:t,refused:r,invalid:i}:{graph:{...e,nodes:o},written:t,refused:r,invalid:i}}s(bI,"addOutcomeSemantics");var mr="bewerbungOffen";function go(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(go,"isObject");var py=["event","effect"];function vI(e){return go(e)&&e.type==="eventTrigger"}s(vI,"isTrigger");function xI(e){let n=go(e.inputs)?e.inputs:{};return"outcomes"in e||py.some(t=>t in e||t in n)}s(xI,"oldShape");function SI(e){return(e?.nodes??[]).some(n=>vI(n)&&xI(n))}s(SI,"needsEventTriggerStartMove");function hz(e){let n=String(e.id),r=(Array.isArray(e.outcomes)?e.outcomes:[]).map(l=>go(l)?l.id:void 0);if("outcomes"in e&&!(r.length===1&&r[0]===mr))return{unmoved:{nodeId:n,reason:"outcomesNotStart"}};let i=Object.keys(go(e.next)?e.next:{});if(!(i.length===1&&i[0]===mr))return{unmoved:{nodeId:n,reason:"nextNotStart"}};let o=go(e.inputs)?{...e.inputs}:{};for(let l of py){let d=o[l];if(go(d)&&d.kind==="binding")return{unmoved:{nodeId:n,reason:"bindingCell"}}}let a={...e};delete a.outcomes;for(let l of py)delete a[l],delete o[l];return go(e.inputs)&&(Object.keys(o).length>0?a.inputs=o:delete a.inputs),{node:a}}s(hz,"moveNode");function AI(e){let n=[],t=[],r=e.nodes.map(i=>{if(!vI(i)||!xI(i))return i;let o=hz(i);return"unmoved"in o?(t.push(o.unmoved),i):(n.push(String(i.id)),o.node)});return n.length===0?{graph:e,moved:n,unmoved:t}:{graph:{...e,nodes:r},moved:n,unmoved:t}}s(AI,"moveEventTriggerStart");function pl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(pl,"isObject");var EI={waitlistOrder:"arrival"};function TI(e){return!pl(e)||e.type!=="waitlist"?!1:!("waitlistOrder"in(pl(e.inputs)?e.inputs:{}))}s(TI,"lacksPolicy");function gz(e){return(e?.nodes??[]).some(TI)}s(gz,"needsWaitlistPolicyMove");function my(e){return pl(e)&&Yt.includes(e.waitlistOrder)}s(my,"isWaitlistPolicy");function yz(e){if(e===void 0)return{policy:EI,stated:!1};if(!pl(e))return"malformed";let n=e.waitlistOrder;return n!==void 0&&!Yt.includes(n)?"malformed":{policy:{waitlistOrder:n??EI.waitlistOrder},stated:n!==void 0}}s(yz,"policyOfSelection");function $I(e,n,t={}){let r=[],i=[];if(!gz(e))return{graph:e,moved:r,refused:i};let o=yz(n),a=e.nodes.map(l=>{if(!TI(l))return l;let d=l,c=String(d.id),u=pl(d.inputs)?{...d.inputs}:{},p=Object.hasOwn(t,c)?t[c]:void 0,m,y;if(p!==void 0)m=p,y="answer";else{if(o==="malformed")return i.push({nodeId:c,reason:"selectionMalformed"}),l;m=o.policy,y=o.stated?"manifest":"formerDefault"}return u.waitlistOrder={kind:"literal",value:m.waitlistOrder},r.push({nodeId:c,policy:m,source:y}),{...d,inputs:u}});return r.length===0?{graph:e,moved:r,refused:i}:{graph:{...e,nodes:a},moved:r,refused:i}}s($I,"moveWaitlistPolicyToInputs");function yo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(yo,"isObject");var wz=[Vn,ho],kz=["inputSchema","parties","schemaDigest","parts"];function RI(e){return yo(e)&&e.type==="governedDocument"&&("resolver"in e||yo(e.template)&&("key"in e.template||"cockpitFields"in e.template))}s(RI,"oldShape");function II(e){return(e?.nodes??[]).some(RI)}s(II,"needsGeneratorInputMove");function bz(e){let n=yo(e.inputs)?{...e.inputs}:{},t={...e},r;if("resolver"in e){let i=e.resolver;if(!yo(i))return{unmoved:"resolverNotObject"};if(Vn in n)return{unmoved:"generatorInputExists"};if(typeof i.key!="string"||i.key.length===0)return{unmoved:"pinWithoutKey"};if(i.kind!=="generator"&&i.kind!=="package")return{unmoved:"pinWithoutKind"};if(i.revision!==void 0&&!(typeof i.revision=="number"&&Number.isInteger(i.revision)&&i.revision>0))return{unmoved:"pinRevisionInvalid"};if((yo(i.inputSchema)&&Array.isArray(i.inputSchema.fields)?i.inputSchema.fields:[]).find(d=>yo(d)&&wz.includes(String(d.key)))!==void 0)return{unmoved:"stampDeclaresReservedKey"};n[Vn]={kind:"literal",value:{kind:i.kind,key:i.key,...i.revision===void 0?{}:{revision:i.revision}}};let l=Object.fromEntries(kz.filter(d=>d in i).map(d=>[d,i[d]]));Object.keys(l).length>0&&(t.generatorStamp=l),r=i.cockpitFields,delete t.resolver}if(yo(e.template)&&("key"in e.template||"cockpitFields"in e.template)){let{key:i,cockpitFields:o,...a}=e.template;if("key"in e.template){if(ho in n)return{unmoved:"templateInputExists"};if(typeof i!="string"||i.length===0)return{unmoved:"templateKeyInvalid"};n[ho]={kind:"literal",value:i}}if(o!==void 0){if(r!==void 0)return{unmoved:"cockpitFieldsTwice"};r=o}t.template=a}if(r!==void 0){if("cockpitFields"in e)return{unmoved:"cockpitFieldsExist"};t.cockpitFields=r}return t.inputs=n,{node:t}}s(bz,"moveNode");function OI(e){let n=[],t=[],r=e.nodes.map(i=>{if(!RI(i))return i;let o=bz(i);return"unmoved"in o?(t.push({nodeId:String(i.id),reason:o.unmoved}),i):(n.push(String(i.id)),o.node)});return n.length===0?{graph:e,moved:n,unmoved:t}:{graph:{...e,nodes:r},moved:n,unmoved:t}}s(OI,"moveGeneratorPinsToInputs");var PI=/^\d{4}-\d{2}-\d{2}$/;function hr(e,n){return{de:e,en:n}}s(hr,"issue");function wo(e){if(typeof e!="object"||e===null)return hr("keine Reduktion","not a reduction");let n=e;if(n.kind==="none")return Object.keys(n).length===1?null:hr('\u201Ekeine Reduktion" tr\xE4gt keine weiteren Angaben','"no reduction" carries no further details');if(n.kind!=="amount")return hr(`unbekannte Art ${JSON.stringify(n.kind)}`,`unknown kind ${JSON.stringify(n.kind)}`);let{amount:t,activeFrom:r,activeTo:i}=n;return typeof t!="number"||!Number.isFinite(t)||t<=0?hr("der Betrag muss gr\xF6\xDFer als 0 \u20AC sein","the amount must be greater than \u20AC0"):Number.isInteger(Number((t*100).toFixed(6)))?typeof r!="string"||!PI.test(r)?hr("der Beginn fehlt (JJJJ-MM-TT)","the start is missing (YYYY-MM-DD)"):typeof i!="string"||!PI.test(i)?hr("das Ende fehlt (JJJJ-MM-TT)","the end is missing (YYYY-MM-DD)"):i<r?hr("das Ende liegt vor dem Beginn","the end is before the start"):n.floorTotal!==void 0&&(typeof n.floorTotal!="number"||!Number.isSafeInteger(n.floorTotal)||n.floorTotal<0)?hr("die Untergrenze muss ein nichtnegativer Centbetrag sein","the floor must be a non-negative amount in cents"):n.pricePeriod!==void 0&&!["month","year","once","unit"].includes(String(n.pricePeriod))?hr("ung\xFCltige Preisperiode","invalid price period"):Object.keys(n).some(o=>!["kind","amount","activeFrom","activeTo","floorTotal","pricePeriod"].includes(o))?hr("unbekannte Angaben","unknown details"):null:hr("der Betrag hat mehr als zwei Nachkommastellen","the amount has more than two decimal places")}s(wo,"reductionShapeIssue");function Oi(e){if(typeof e!="object"||e===null)return!1;let n=e;return typeof n.itemKey=="string"&&n.itemKey.length>0&&Array.isArray(n.grantKeys)&&n.grantKeys.every(t=>typeof t=="string"&&t.length>0)&&(n.reduction===void 0||wo(n.reduction)===null&&n.reduction.kind==="amount")}s(Oi,"isPricedItemValue");var vs=["freetext","recommendation","choice","pricedItem","record","reduction"],xs=[...vs,"appointment"];function _I(e){return typeof e=="string"&&xs.includes(e)}s(_I,"isTaskResultKind");function Pi(e){return typeof e=="string"&&vs.includes(e)}s(Pi,"isRecordedTaskResultKind");function Ss(e){return Pi(e.kind)}s(Ss,"isRecordedTaskResult");var hf=["number","boolean","enum"];function hy(e){return typeof e=="string"&&hf.includes(e)}s(hy,"isRecordFieldType");var gy=["form","siblingRank"];var ti={freetext:{choiceValueType:null,valueType:null,textValueType:"string",label:{de:"Freitext",en:"Free text"}},recommendation:{choiceValueType:"enum",valueType:null,textValueType:"string",label:{de:"Empfehlung",en:"Recommendation"}},choice:{choiceValueType:"enum",valueType:"enum",textValueType:"string",label:{de:"Auswahl",en:"Choice"}},pricedItem:{choiceValueType:"enum",valueType:"pricedItem",textValueType:"string",label:{de:"Preisposition",en:"Priced item"}},reduction:{choiceValueType:null,valueType:"reduction",textValueType:"string",label:{de:"Reduktion",en:"Reduction"}},record:{choiceValueType:null,valueType:null,textValueType:"string",label:{de:"Erfassung",en:"Record"}},appointment:{choiceValueType:null,valueType:null,textValueType:null,label:{de:"Termin",en:"Appointment"}}};function CI(e){return(e.kind==="freetext"||e.kind==="recommendation"||e.kind==="choice")&&e.writes===void 0}s(CI,"isProseResult");function gf(e){return e.kind==="record"?(e.fields??[]).filter(n=>typeof n.writes=="string"&&n.writes.length>0&&hy(n.type)).map(n=>({key:n.writes,valueType:n.type,field:n})):vz(e)}s(gf,"draftResultStoreWrites");function vz(e){let n=ti[e.kind].valueType;return e.writes===void 0||n===null?[]:[{key:e.writes,valueType:n}]}s(vz,"singleStoreWrite");var NI="team:";function As(e){if(e==="all")return{kind:"all"};if(e==="external"||e.length===0)return null;if(e.startsWith(NI)){let n=e.slice(NI.length);return n.length===0?null:{kind:"team",groupKey:n}}return{kind:"channel",channelKey:e}}s(As,"parseTaskResultChat");var Ze={unknownKind:"[taskResult/unknownKind]",onApproval:"[taskResult/onApproval]",unknownField:"[taskResult/unknownField]",choiceOptions:"[taskResult/choiceOptions]",textRequiredOnFreetext:"[taskResult/textRequiredOnFreetext]",chatMissing:"[taskResult/chatMissing]",chatExternal:"[taskResult/chatExternal]",chatUnknownChannel:"[taskResult/chatUnknownChannel]",appointmentMissingTitle:"[taskResult/appointmentMissingTitle]",pricedItemMissingItem:"[taskResult/pricedItemMissingItem]",pricedItemUnknownItem:"[taskResult/pricedItemUnknownItem]",pricedItemNotInProgram:"[taskResult/pricedItemNotInProgram]",pricedItemOfferWithoutProgram:"[taskResult/pricedItemOfferWithoutProgram]",itemOnNonPricedItem:"[taskResult/itemOnNonPricedItem]",writesOnProse:"[taskResult/writesOnProse]",labelMissing:"[taskResult/labelMissing]",appointmentInvalidDuration:"[taskResult/appointmentInvalidDuration]",recordFields:"[taskResult/recordFields]",fieldsOnNonRecord:"[taskResult/fieldsOnNonRecord]",recordSuggest:"[taskResult/recordSuggest]",reductionPrices:"[taskResult/reductionPrices]",pricesOnNonReduction:"[taskResult/pricesOnNonReduction]"};var xz=new Set(["if","else","in","true","false","null"]),Sz=new Set(["==","!=","<=",">=","&&","||"]);function Az(e){return e>="0"&&e<="9"}s(Az,"isDigit");function Ez(e){return/[a-zA-Z_$]/.test(e)}s(Ez,"isIdentStart");function Tz(e){return/[a-zA-Z0-9_.$]/.test(e)}s(Tz,"isIdentCont");function $z(e){let n=[],t=0;for(;t<e.length;){let r=e.charAt(t);if(r===" "||r===" "||r===`
|
|
10942
10945
|
`||r==="\r"){t++;continue}if(r==="'"){let o=t+1,a="";for(;o<e.length&&e.charAt(o)!=="'";)e.charAt(o)==="\\"&&o+1<e.length?(a+=e.charAt(o+1),o+=2):(a+=e.charAt(o),o++);o>=e.length&&F(`Unterminated string at ${t}`),n.push({t:"str",v:a}),t=o+1;continue}if(Az(r)){let o=t;for(;o<e.length&&/[0-9.]/.test(e.charAt(o));)o++;n.push({t:"num",v:Number(e.slice(t,o))}),t=o;continue}if(Ez(r)){let o=t;for(;o<e.length&&Tz(e.charAt(o));)o++;let a=e.slice(t,o);xz.has(a)?n.push({t:"kw",v:a}):n.push({t:"ident",v:a}),t=o;continue}let i=e.slice(t,t+2);if(Sz.has(i)){n.push({t:"op",v:i}),t+=2;continue}if("<>!".includes(r)){n.push({t:"op",v:r}),t++;continue}if("()[],".includes(r)){n.push({t:"punct",v:r}),t++;continue}F(`Unexpected char '${r}' at ${t}`)}return n}s($z,"tokenise");var DI=1e4,FI=128;function Es(e){e.depth++,e.depth>FI&&F(`Expression nesting too deep (> ${FI})`)}s(Es,"enterDepth");function BI(e){return e.pos<e.tokens.length?e.tokens[e.pos]:null}s(BI,"peek");function Un(e){let n=e.tokens[e.pos];return n||F(`Unexpected end at ${e.pos}`),e.pos++,n}s(Un,"take");function Gn(e,n,t){let r=BI(e);return!(!r||r.t!==n||t!==void 0&&r.v!==t)}s(Gn,"match");function ko(e,n,t){return Gn(e,n,t)||F(`Expected ${n}${t?`:${t}`:""} at ${e.pos}`),Un(e)}s(ko,"expect");function ii(e){Es(e);try{return Gn(e,"kw","if")?Rz(e):Iz(e)}finally{e.depth--}}s(ii,"parseExpr");function Rz(e){ko(e,"kw","if"),ko(e,"punct","(");let n=ii(e);ko(e,"punct",")");let t=ii(e);ko(e,"kw","else");let r=ii(e);return{kind:"if",cond:n,then:t,else:r}}s(Rz,"parseIf");function Iz(e){let n=LI(e),t=0;try{for(;Gn(e,"op","||");){Un(e),Es(e),t++;let r=LI(e);n={kind:"binary",op:"||",left:n,right:r}}}finally{e.depth-=t}return n}s(Iz,"parseLogicOr");function LI(e){let n=MI(e),t=0;try{for(;Gn(e,"op","&&");){Un(e),Es(e),t++;let r=MI(e);n={kind:"binary",op:"&&",left:n,right:r}}}finally{e.depth-=t}return n}s(LI,"parseLogicAnd");function MI(e){let n=qI(e),t=0;try{for(;Gn(e,"op","==")||Gn(e,"op","!=");){let r=Un(e).v;Es(e),t++;let i=qI(e);n={kind:"binary",op:r,left:n,right:i}}}finally{e.depth-=t}return n}s(MI,"parseEquality");function qI(e){let n=wy(e),t=0;try{for(;Gn(e,"op","<")||Gn(e,"op","<=")||Gn(e,"op",">")||Gn(e,"op",">=")||Gn(e,"kw","in");){let r=Un(e),i=r.t==="kw"?"in":r.v;Es(e),t++;let o=wy(e);n={kind:"binary",op:i,left:n,right:o}}}finally{e.depth-=t}return n}s(qI,"parseCompare");function wy(e){if(Gn(e,"op","!")){Un(e),Es(e);try{return{kind:"unary",op:"!",operand:wy(e)}}finally{e.depth--}}return Oz(e)}s(wy,"parseUnary");function Oz(e){let n=BI(e);if(n||F("Unexpected end"),n.t==="num")return Un(e),{kind:"num",value:n.v};if(n.t==="str")return Un(e),{kind:"str",value:n.v};if(n.t==="kw"&&n.v==="true")return Un(e),{kind:"bool",value:!0};if(n.t==="kw"&&n.v==="false")return Un(e),{kind:"bool",value:!1};if(n.t==="kw"&&n.v==="null")return Un(e),{kind:"null"};if(n.t==="punct"&&n.v==="("){Un(e);let t=ii(e);return ko(e,"punct",")"),t}if(n.t==="punct"&&n.v==="["){Un(e);let t=[];if(!Gn(e,"punct","]"))for(t.push(ii(e));Gn(e,"punct",",");)Un(e),t.push(ii(e));return ko(e,"punct","]"),{kind:"arr",items:t}}if(n.t==="ident"){let t=n.v;if(Un(e),Gn(e,"punct","(")){Un(e);let r=[];if(!Gn(e,"punct",")"))for(r.push(ii(e));Gn(e,"punct",",");)Un(e),r.push(ii(e));return ko(e,"punct",")"),{kind:"call",name:t,args:r}}return{kind:"ident",path:t}}F(`Unexpected token at ${e.pos}`)}s(Oz,"parsePrimary");function In(e){e.length>DI&&F(`Expression too long (${e.length} > ${DI})`);let n={tokens:$z(e),pos:0,depth:0},t=ii(n);return n.pos<n.tokens.length&&F(`Unexpected trailing token at ${n.pos}`),t}s(In,"parseExpression");var Pz=new Map([["today",()=>new Date().toISOString().slice(0,10)],["years_between",(e,n)=>{if(typeof e!="string"||typeof n!="string")return null;let t=new Date(e),r=new Date(n);if(isNaN(t.getTime())||isNaN(r.getTime()))return null;let i=r.getFullYear()-t.getFullYear(),o=r.getMonth()-t.getMonth();return(o<0||o===0&&r.getDate()<t.getDate())&&i--,i}],["length",e=>typeof e=="string"||Array.isArray(e)?e.length:0]]);function un(e,n){switch(e.kind){case"num":return e.value;case"str":return e.value;case"bool":return e.value;case"null":return null;case"ident":{let t=Object.hasOwn(n.values,e.path)?n.values[e.path]:void 0;return t===void 0?null:t}case"arr":return e.items.map(t=>un(t,n));case"unary":{let t=un(e.operand,n);return!Ni(t)}case"call":{let t=n.functions!==void 0&&Object.hasOwn(n.functions,e.name)?n.functions[e.name]:Pz.get(e.name);t||F(`Unknown function '${e.name}'`);let r=e.args.map(i=>un(i,n));return t(...r)}case"binary":return Nz(e.op,e.left,e.right,n);case"if":return Ni(un(e.cond,n))?un(e.then,n):un(e.else,n)}}s(un,"evaluate");function Nz(e,n,t,r){if(e==="&&"){let a=un(n,r);return Ni(a)?Ni(un(t,r)):!1}if(e==="||"){let a=un(n,r);return Ni(a)?!0:Ni(un(t,r))}let i=un(n,r),o=un(t,r);switch(e){case"==":return yy(i,o);case"!=":return!yy(i,o);case"<":{let[a,l]=yf(i,o);return a!==null&&l!==null&&a<l}case"<=":{let[a,l]=yf(i,o);return a!==null&&l!==null&&a<=l}case">":{let[a,l]=yf(i,o);return a!==null&&l!==null&&a>l}case">=":{let[a,l]=yf(i,o);return a!==null&&l!==null&&a>=l}case"in":return Array.isArray(o)?o.some(a=>yy(a,i)):!1}}s(Nz,"evalBinary");function yf(e,n){return[KI(e),KI(n)]}s(yf,"orderedOperands");function KI(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"){if(e.trim()==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}return null}s(KI,"numericOperand");function yy(e,n){return e===n?!0:e==null||n==null?!1:typeof e=="number"&&typeof n=="string"?e===Number(n):typeof e=="string"&&typeof n=="number"?Number(e)===n:!1}s(yy,"looseEq");function Ni(e){return!(e==null||e===!1||e===0||e===""||Array.isArray(e)&&e.length===0)}s(Ni,"truthy");function xn(e){let n=new Set;return ri(e,n),[...n]}s(xn,"dependencies");function ri(e,n){switch(e.kind){case"ident":n.add(e.path);return;case"call":e.args.forEach(t=>ri(t,n));return;case"arr":e.items.forEach(t=>ri(t,n));return;case"unary":ri(e.operand,n);return;case"binary":ri(e.left,n),ri(e.right,n);return;case"if":ri(e.cond,n),ri(e.then,n),ri(e.else,n);return;default:return}}s(ri,"walk");var jI=new Map;function gr(e){let n=jI.get(e);return n||(n=In(e),jI.set(e,n)),n}s(gr,"parseCached");function _z(e,n){return un(gr(e),n)}s(_z,"evalExpression");function VI(e,n){return Ni(_z(e,n))}s(VI,"evalBoolean");function wf(e){let n=e.pricingRules;return n===void 0?[]:(Array.isArray(n)||F("graph.pricingRules must be an array \u2014 the graph validator refuses anything else"),n)}s(wf,"pricingRuleSets");function ky(e){return e.derive!==void 0}s(ky,"isDerivedKey");function Cz(e,n){let t=wf(e);return(n.rules??[]).map(r=>{let i=t.find(o=>o.key===r);return i===void 0&&F(`[process] derivation names the unknown rule set "${r}" \u2014 publish refuses that`),i})}s(Cz,"ruleSetsOfDerivation");function GI(e){return[...new Set(e.rows.flatMap(n=>xn(gr(n.when))))]}s(GI,"ruleSetDependencies");function zI(e){let n=Zr(e);return n!==null&&se(n)===e?n:null}s(zI,"ruleIdentifierAddress");function by(e,n){let r=[...new Set(Cz(e,n).flatMap(GI))].map(o=>{let a=zI(o);return a===null&&F(`[address/bareIdentifier] rule identifier "${o}" is no address \u2014 publish refuses that`),{address:a,id:o,role:"rule"}}),i=n.reduction;return i===void 0?r:(we(i)||F(`[address/bareIdentifier] derive.reduction ${JSON.stringify(i)} is no address \u2014 publish refuses that`),[...r,{address:i,id:se(i),role:"reduction"}])}s(by,"derivationSources");function WI(e,n){let t=wf(e);for(let r of n.rules??[]){let i=t.find(o=>o.key===r);if(i===void 0||i.rows.some(o=>ml(o.when)!==null)||GI(i).some(o=>zI(o)===null))return null}return n.reduction!==void 0&&!we(n.reduction)?null:by(e,n)}s(WI,"draftDerivationSources");function ml(e){if(typeof e!="string"||e.trim().length===0)return"leere Bedingung";try{return gr(e),null}catch(n){return n instanceof Error?n.message:String(n)}}s(ml,"conditionIssue");function UI(e){return e.item!==void 0&&e.group===void 0?{kind:"item",key:e.item}:e.group!==void 0&&e.item===void 0?{kind:"group",key:e.group}:null}s(UI,"rowTarget");function vy(e){if(e.byStage===void 0){let n=UI(e);return n===null?[]:[{...n,stages:null}]}return e.item!==void 0||e.group!==void 0?[]:e.byStage.flatMap(n=>{let t=UI(n);return t===null?[]:[{...t,stages:n.stages}]})}s(vy,"derivationTargets");function YI(e,n){n!==null&&(typeof n=="object"||typeof n=="function")&&Object.hasOwn(n,"exports")&&F(`[workflow/registry] node type "${e}": custom spec.exports is unsupported; use artifact-slot exports.`)}s(YI,"assertNoCustomNodeExports");var xy=null;function HI(e){for(let[n,t]of Object.entries(e))YI(n,t);xy=e}s(HI,"setSpecs");function JI(){return xy||F("[workflow/registry] Specs not initialised. Import convex/model/admission/specs before calling specFor()."),xy}s(JI,"requireSpecs");function He(e){let n=JI(),t=n[e.type];return t===void 0&&le("INVALID",{de:`[workflow/registry] Unbekannter Knotentyp "${String(e.type)}" (Knoten "${String(e.id)}"). Registrierte Typen: ${Object.keys(n).sort().join(", ")}.`,en:`[workflow/registry] Unknown node type "${String(e.type)}" (node "${String(e.id)}"). Registered types: ${Object.keys(n).sort().join(", ")}.`}),t}s(He,"specFor");function QI(){return Object.keys(JI()).sort()}s(QI,"registeredNodeTypes");var ZI=of.filter(e=>ei[e].cohortBound!==!0);function Sy(e){return Wt(e)&&ei[e].cohortBound!==!0}s(Sy,"isEnvAddressLeaf");function Ay(e){return mo(e).type}s(Ay,"envType");function Ey(e){return mo(e).label}s(Ey,"envLabel");function kf(e){if(e.scope==="env"||e.path===void 0)return e;switch(e.scope){case"node":return{scope:"node",owner:e.owner,key:e.key};case"task":return{scope:"task",owner:e.owner,key:e.key};case"derived":return{scope:"derived",key:e.key}}}s(kf,"addressBase");function wr(e){return e.scope==="node"&&e.key===it&&e.path===void 0}s(wr,"isInstanceAddress");function fn(e){return we(e)&&e.scope==="node"&&e.key===it&&e.path!==void 0}s(fn,"isFormFieldAddress");function XI(e){return fn(e)?{owner:e.owner,path:e.path}:null}s(XI,"formFieldOf");function Ty(e){return xn(gr(e)).map(n=>{if(!n.startsWith("$"))return{identifier:n,address:null,reason:"bareIdentifier"};let t=Zr(n);return t===null?{identifier:n,address:null,reason:"shape"}:{identifier:n,address:t}})}s(Ty,"expressionAddresses");var it="admission",wl="document",Ts="contract",$s="contracts",eO="payment",$y=new Set(["adoptForm","setFlagTarget","form","familyRequestFrom"]);var ct={id:"identity",type:"identity",label:"display",sublabel:"display",library:"display",outcomes:"control",outputLabels:"display",inputs:"input",next:"control",tasks:"config",assign:"reference",actionTeams:"reference",optionalActions:"config",artifacts:"config",notifications:"config"},Kde={join:{...ct},end:{...ct},eventTrigger:{...ct},form:{...ct,adoptForm:"address",formExports:"stamp"},roleAssign:{...ct},setFlag:{...ct},if:{...ct,condition:"address"},countersign:{...ct,contract:"address",titles:"display",signing:"config"},engagePush:{...ct,engage:"tenantRef",form:"address",contract:"address",payment:"address"},decision:{...ct,commentRequired:"config",decisionAsTask:"config",reads:"address",formView:"config",requiresOneOf:"config"},review:{...ct,form:"address",commentRequired:"config",decisionAsTask:"config"},waitlist:{...ct},completenessCheck:{...ct,requires:"address",deadline:"config"},collectPayment:{...ct},governedDocument:{...ct,production:"config",form:"address",generatorStamp:"stamp",templateStamp:"stamp",approval:"config",confirmBeforeIssue:"config",confirmContractTerms:"config",contractTermsQuestionText:"display",responseStrategy:"config",titles:"display",responseLabels:"display",reads:"address"}};function yr(e){return Array.isArray(e)?e:[]}s(yr,"listOf");function Ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}s(Ln,"record");function nO(e){switch(e.type){case"countersign":return["contract"];case"engagePush":return["form","contract","payment"];case"governedDocument":return e.production==="resolver"?["form"]:[];case"review":return["form"];default:return[]}}s(nO,"dataSourceFieldsOf");function tO(e){return e.type==="review"?[]:e.type==="engagePush"?["form"]:nO(e)}s(tO,"requiredDataSourceFields");var Dz={setFlag:{target:"setFlagTarget"}};function kl(e,n={}){let t=[],r=e,i=`nodes.${e.id}`,o=s((d,c,u,p={})=>{t.push({kind:d,at:c,nodeId:e.id,value:u,judgedTogether:null,...p})},"field"),a=new Map(n.slotTypes===!1?[]:(He(e).inputs?.(e)??[]).map(d=>[d.id,d.type])),l=Dz[e.type]??{};for(let[d,c]of Object.entries(Ln(r.inputs)??{})){let u=Ln(c);if(u?.kind!=="binding")continue;let p="address"in u?u.address:u.path,m=l[d];if(m!==void 0){o(m,`${i}.inputs.${d}`,p);continue}let y=a.get(d);o("binding",`${i}.inputs.${d}`,p,y!==void 0?{expectedType:y}:{})}for(let[d,c]of yr(r.reads).entries())o("nodeReads",`${i}.reads.${d}`,c,{judgedTogether:`${i}.reads`});for(let[d,c]of yr(r.requires).entries())o("requires",`${i}.requires.${d}`,c,{judgedTogether:`${i}.requires`});e.type==="form"&&r.adoptForm!==void 0&&o("adoptForm",`${i}.adoptForm`,r.adoptForm);for(let d of nO(e))r[d]!==void 0&&o(d,`${i}.${d}`,r[d]);e.type==="if"&&r.condition!==void 0&&o("condition",`${i}.condition`,r.condition);for(let[d,c]of yr(r.tasks).entries())t.push(...rO(e.id,c,d));for(let[d,c]of yr(r.optionalActions).entries()){let u=Ln(c);u?.when!==void 0&&o("optionalActionWhen",Fz(e.id,typeof u.key=="string"?u.key:String(d)),u.when)}return t}s(kl,"nodeAddressFields");function Fz(e,n){return`nodes.${e}.optionalActions.${n}.when`}s(Fz,"optionalActionWhenPath");function rO(e,n,t){let r=Ln(n);if(r===null)return[];let i=[],o=typeof r.key=="string"?r.key:String(t),a=`nodes.${e}.tasks.${o}`,l=s((p,m,y,k={})=>{i.push({kind:p,at:m,nodeId:e,taskKey:o,value:y,judgedTogether:null,...k})},"field"),d=`${a}.evidence`;r.when!==void 0&&l("taskWhen",`${a}.when`,r.when,{expectedType:"boolean",judgedTogether:d});for(let[p,m]of yr(r.reads).entries())l("taskReads",`${a}.reads.${p}`,m,{judgedTogether:d});for(let[p,m]of yr(r.documents).entries()){let y=Ln(m);y===null||y.kind==="artifact"||l("taskDocument",`${a}.documents.${p}`,"address"in y?y.address:y.key)}let c=Ln(r.familyRequest);if(c!==null){for(let[p,m]of yr(c.fields).entries())l("familyRequestFields",`${a}.familyRequest.fields.${p}`,m,{judgedTogether:`${a}.familyRequest.fields`});c.from!==void 0&&l("familyRequestFrom",`${a}.familyRequest.from`,c.from)}let u=Ln(r.result);if(u?.kind==="record")for(let[p,m]of yr(u.fields).entries()){let y=Ln(Ln(m)?.suggest);if(y?.kind!=="form")continue;let k=Ln(m)?.type;l("suggest",`${a}.result.fields.${p}.suggest`,"address"in y?y.address:y.key,typeof k=="string"?{expectedType:k}:{})}return i}s(rO,"taskAddressFields");function bf(e){let n=[];for(let[t,r]of yr(e.processStore).entries()){let i=Ln(Ln(r)?.derive);if(i?.reduction!==void 0){let o=String(Ln(r)?.key);n.push({kind:"reduction",at:`processStore.${t}.derive.reduction`,nodeId:null,priceKey:o,value:i.reduction,judgedTogether:null})}}for(let[t,r]of yr(e.pricingRules).entries())for(let[i,o]of yr(Ln(r)?.rows).entries())n.push({kind:"pricingRule",at:`pricingRules.${t}.rows.${i}.when`,nodeId:null,value:Ln(o)?.when,judgedTogether:null});return n}s(bf,"priceAddressFields");function Rs(e){return Ry(e)?(vf(e.value)??[]).flatMap(n=>n.address===null?[]:[n.address]):we(e.value)?[e.value]:[]}s(Rs,"addressesInField");function Ry(e){return e.kind==="pricingRule"||e.kind==="condition"||e.kind==="optionalActionWhen"}s(Ry,"isExpressionField");function vf(e){return ml(e)===null?Ty(e):null}s(vf,"ruleConditionAddresses");function vt(e){return e.type==="form"&&e.adoptForm!==void 0&&e.adoptForm!==!1}s(vt,"adoptsForm");function iO(e){if(e.type!=="form"||vt({type:e.type,adoptForm:e.adoptForm}))return;let n=e.inputs?.smartForm;return n?.kind==="literal"&&typeof n.value=="string"&&n.value!==""?n.value:void 0}s(iO,"createdSmartFormSlug");function Lz(e,n){return e.type!=="governedDocument"||e.production!=="resolver"||n!==wl?n:e.generatorStamp?.parts!==void 0?$s:Ts}s(Lz,"addressKeyOfPort");function Iy(e){let n=e.result;return n===void 0||!Ss(n)?[]:gf(n).map(t=>t.key)}s(Iy,"storeWritesOf");function gl(e,n){return(Array.isArray(e.processStore)?e.processStore:[]).find(t=>t.key===n)}s(gl,"declaredKey");function Dr(e,n){let t=[];if(!vt(n))for(let r of He(n).outputs?.(n)??[])t.push({address:{scope:"node",owner:n.id,key:Lz(n,r.name)},type:r.type,...r.label!==void 0?{label:r.label}:{},nodeId:n.id,nodePort:r});for(let r of Array.isArray(n.tasks)?n.tasks:[])for(let i of Iy(r)){let o=gl(e,i);t.push({address:{scope:"task",owner:r.key,key:i},type:o?.type??"unknown",...o!==void 0?{label:o.label}:{},nodeId:n.id})}return t}s(Dr,"producedAddresses");function oO(e,n,t){for(let r of e.nodes)for(let i of Array.isArray(r.tasks)?r.tasks:[])if(i.key===n&&Iy(i).includes(t))return{nodeId:r.id,template:i};return null}s(oO,"taskWriter");function Fr(e,n,t){return oO(e,n,t)?.nodeId??null}s(Fr,"taskOwnerNode");function yl(e,n){let t=gl(e,n)?.derive;if(t===void 0)return null;let r=Array.isArray(e.pricingRules)?e.pricingRules:[],i=[];for(let a of t.rules??[]){let l=r.find(d=>d.key===a);if(l===void 0)return null;for(let d of l.rows){let c=vf(d.when);if(c===null)return null;for(let u of c)u.address!==null&&i.push(u.address)}}let o=t.reduction;return we(o)&&i.push(o),Mz(i)}s(yl,"derivedSources");function Mz(e){let n=new Set;return e.filter(t=>{let r=se(t);return n.has(r)?!1:(n.add(r),!0)})}s(Mz,"dedupe");function qz(e){return kl(e,{slotTypes:!1}).flatMap(n=>Rs(n).map(t=>({address:t,field:n})))}s(qz,"writtenAddressesOf");function bo(e,n){let t=[],r=new Set,i=s((l,d,c,u)=>{let p=`${se(l)}|${d}|${c.at}|${u===void 0?"":se(u)}`;r.has(p)||(r.add(p),t.push({address:l,origin:d,field:c,...u!==void 0?{via:u}:{}}))},"push"),o=s((l,d,c=new Set)=>{let u=se(l);if(!c.has(u)){if(c.add(u),l.scope==="task"){let p=oO(e,l.owner,l.key);if(p===null)return;for(let m of rO(p.nodeId,p.template))if(!(m.kind!=="taskWhen"&&m.kind!=="taskReads"))for(let y of Rs(m))i(y,"evidence",d,l)}if(l.scope==="derived")for(let p of yl(e,l.key)??[])i(p,"derivedSource",d,l),o(p,d,c)}},"carried");for(let{address:l,field:d}of qz(n))i(l,"written",d),o(l,d);let a=new Set((Array.isArray(n.tasks)?n.tasks:[]).flatMap(l=>Iy(l).map(d=>`${l.key}.${d}`)));for(let l of bf(e))if(!(l.kind!=="reduction"||!we(l.value)||l.value.scope!=="task")&&a.has(`${l.value.owner}.${l.value.key}`))for(let d of yl(e,l.priceKey)??[])d.scope==="task"&&a.has(`${d.owner}.${d.key}`)||(i(d,"priceCheck",l,{scope:"derived",key:l.priceKey}),o(d,l));return t}s(bo,"addressReadsOf");function Oy(e,n){switch(n.scope){case"env":return Wt(n.key)?Ay(n.key):ks(e,n.key)?.type;case"derived":case"task":{if(n.path!==void 0||n.scope==="task"&&Fr(e,n.owner,n.key)===null)return;let t=gl(e,n.key);return t===void 0||n.scope==="derived"!=(t.derive!==void 0)?void 0:t.type}case"node":{let t=e.nodes.find(i=>i.id===n.owner);if(t===void 0)return;let r=Dr(e,t).find(i=>i.address.scope==="node"&&i.address.key===n.key);return r===void 0?void 0:n.path===void 0?r.type:r.nodePort?.schema?.find(i=>i.key===n.path)?.type}}}s(Oy,"addressType");function hl(e,n){let t=Ln(e)?.[n];return typeof t=="string"&&t.length>0?t:void 0}s(hl,"labelText");function Oe(e,n,t){let r=e.nodes.find(i=>i.id===n);return hl(r?.label,t)??n}s(Oe,"nodeDisplayName");function vo(e,n,t){for(let r of e.nodes){let i=(Array.isArray(r.tasks)?r.tasks:[]).find(o=>o.key===n);if(i!==void 0)return hl(i.title,t)??n}return n}s(vo,"taskDisplayName");function Ve(e,n,t){let r=[];switch(n.scope){case"env":r.push(Wt(n.key)?Ey(n.key)[t]:ks(e,n.key)?.label[t]??n.key);break;case"derived":r.push(hl(gl(e,n.key)?.label,t)??n.key);break;case"task":r.push(vo(e,n.owner,t),hl(gl(e,n.key)?.label,t)??n.key);break;case"node":{r.push(Oe(e,n.owner,t));let i=e.nodes.find(a=>a.id===n.owner),o=i===void 0?void 0:Dr(e,i).find(a=>a.address.scope==="node"&&a.address.key===n.key);r.push(hl(o?.label,t)??n.key);break}}return n.scope!=="env"&&n.path!==void 0&&r.push(n.path),`${r.join(" \u203A ")} (${se(n)})`}s(Ve,"displayAddress");var bl=["beneficiary","signers"];function sO(e,n){return Array.isArray(e.artifacts)&&e.artifacts.some(t=>t?.key===n)}s(sO,"ownsSlot");function vl(e){let n=[];for(let[t,r]of Object.entries(Ln(e.inputs)??{})){let i=Ln(r);i?.kind==="binding"&&we(i.address)&&n.push({slot:t,address:i.address})}return n}s(vl,"bindingAddresses");function aO(e,n){return vl(e).find(t=>t.slot===n)?.address??null}s(aO,"bindingAddressAt");function lO(e,n){let t=s(i=>i.scope==="node"&&i.owner===n||i.scope==="task"&&Fr(e,i.owner,i.key)===n,"names");return[...e.nodes.filter(i=>i.id!==n).flatMap(i=>kl(i,{slotTypes:!1})),...bf(e)].flatMap(i=>Rs(i).filter(t).map(o=>({at:i.at,nodeId:i.nodeId,address:o})))}s(lO,"addressesNaming");var On={target:"target",flagKey:"flagKey",value:"value"};function Kz(e){return aO(e,On.target)}s(Kz,"setFlagTarget");function dO(e){let n=Kz(e);return n!==null&&wr(n)?n.owner:null}s(dO,"setFlagTargetOwner");function xf(e){let n=e.inputs?.[On.flagKey];return n?.kind==="literal"&&typeof n.value=="string"&&n.value.length>0?n.value:null}s(xf,"setFlagKey");function cO(e){let n=e.inputs?.[On.value];if(n===void 0||n.kind==="unset")return!0;if(n.kind==="literal"&&typeof n.value=="boolean")return n.value;F(`[setFlag/valueType] setFlag node "${String(e.id)}": \`${On.value}\` is no yes/no literal \u2014 publish refuses that`)}s(cO,"setFlagValue");function uO(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(uO,"isObject");var fO=["target","flagKey","value"];function pO(e){return uO(e)&&e.type==="setFlag"&&fO.some(n=>n in e)}s(pO,"oldShape");function mO(e){return(e?.nodes??[]).some(pO)}s(mO,"needsSetFlagInputMove");function jz(e){let n=uO(e.inputs)?{...e.inputs}:{};if(fO.some(a=>a in e&&On[a]in n))return{unmoved:"inputExists"};if("target"in e&&!we(e.target))return{unmoved:"targetNotAddress"};if("flagKey"in e&&typeof e.flagKey!="string")return{unmoved:"flagKeyNotString"};if("value"in e&&typeof e.value!="boolean")return{unmoved:"valueNotBoolean"};let{target:t,flagKey:r,value:i,...o}=e;return t!==void 0&&(n[On.target]={kind:"binding",address:t}),typeof r=="string"&&r.length>0&&(n[On.flagKey]={kind:"literal",value:r}),i!==void 0&&(n[On.value]={kind:"literal",value:i}),{node:{...o,inputs:n}}}s(jz,"moveNode");function hO(e){let n=[],t=[],r=e.nodes.map(i=>{if(!pO(i))return i;let o=jz(i);return"unmoved"in o?(t.push({nodeId:String(i.id),reason:o.unmoved}),i):(n.push(String(i.id)),o.node)});return n.length===0?{graph:e,moved:n,unmoved:t}:{graph:{...e,nodes:r},moved:n,unmoved:t}}s(hO,"moveSetFlagConfigToInputs");function gO(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(gO,"isObject");var Py={countersign:{dueInDays:"number"},decision:{allowSkipInTest:"boolean"},completenessCheck:{guestRole:"string"},governedDocument:{responseDueInDays:"number"}},Ny={review:["allowSkipInTest"]};function yO(e){return Py[String(e)]??{}}s(yO,"movesOf");function wO(e){return Ny[String(e)]??[]}s(wO,"deadOf");function kO(e){return gO(e)&&[...Object.keys(yO(e.type)),...wO(e.type)].some(n=>n in e)}s(kO,"oldShape");function bO(e){return(e?.nodes??[]).some(kO)}s(bO,"needsScalarInputMove");function Bz(e,n){return n==="number"?typeof e=="number"&&Number.isInteger(e)&&e>=1:typeof e===n}s(Bz,"wellTyped");function Vz(e){let n=gO(e.inputs)?{...e.inputs}:{},t={...e};for(let[r,i]of Object.entries(yO(e.type))){if(!(r in e))continue;let o=e[r];if(r in n)return{unmoved:{nodeId:String(e.id),key:r,reason:"inputExists"}};if(!(i==="string"&&o==="")&&!Bz(o,i))return{unmoved:{nodeId:String(e.id),key:r,reason:"valueWrongType"}};o!==""&&(n[r]={kind:"literal",value:o}),delete t[r]}for(let r of wO(e.type))delete t[r];return t.inputs=n,{node:t}}s(Vz,"moveNode");function vO(e){let n=[],t=[],r=e.nodes.map(i=>{if(!kO(i))return i;let o=Vz(i);return"unmoved"in o?(t.push(o.unmoved),i):(n.push(String(i.id)),o.node)});return n.length===0?{graph:e,moved:n,unmoved:t}:{graph:{...e,nodes:r},moved:n,unmoved:t}}s(vO,"moveScalarConfigToInputs");var Is={team:{label:{de:"Team",en:"Team"},optionSource:"tenantTeams",existence:{check:"generic",catalog:"teamKeys"}},roleKey:{label:{de:"Rolle",en:"Role"},optionSource:"tenantRoles",existence:{check:"node",codes:["roleAssign/unknownRoleKey","completenessCheck/unknownRole"]}},article:{label:{de:"Artikel",en:"Article"},optionSource:"programArticles",existence:{check:"node",codes:["collectPayment/unknownArticle"]}},legalEntity:{label:{de:"Tr\xE4ger",en:"Legal entity"},optionSource:"tenantTraeger",existence:{check:"node",codes:["governedDocument/unknownTraeger","collectPayment/unknownPayee"]}},contractGenerator:{label:{de:"Vertragsgenerator",en:"Contract generator"},optionSource:"tenantGenerators",existence:{check:"publish",by:"admittedGeneratorByKey"}},documentTemplate:{label:{de:"Dokumentvorlage",en:"Document template"},optionSource:"tenantDocumentTemplates",existence:{check:"publish",by:"governedDocument/unknownTemplate"}},smartForm:{label:{de:"Formular",en:"Form"},optionSource:"offerSmartForms",existence:{check:"publish",by:"form/unknownSmartForm"}},unit:{label:{de:"Einrichtung",en:"Unit"},optionSource:"tenantUnits",existence:{check:"generic",catalog:"unitKeys"}},formFlag:{label:{de:"Merkmal im Formular",en:"Flag in the form"},optionSource:"targetFormFlags",existence:{check:"node",codes:["setFlag/unknownFlag"]}}};function Sf(e){return typeof e=="string"&&Object.hasOwn(Is,e)}s(Sf,"isResourceType");var nce=Object.keys(Is).filter(e=>Is[e].existence.check==="generic");function xO(e){if(typeof e!="object"||e===null)return!1;let n=e;return typeof n.groupKey=="string"&&n.groupKey.length>0&&Array.isArray(n.grantKeys)&&n.grantKeys.every(t=>typeof t=="string"&&t.length>0)&&(n.reduction===void 0||wo(n.reduction)===null&&n.reduction.kind==="amount")&&Object.keys(n).every(t=>t==="groupKey"||t==="grantKeys"||t==="reduction")}s(xO,"isPricedGroupValue");var _y=["street","hausnr","plz","ort","land"];function SO(e){return _y.includes(e)}s(SO,"isAddressPart");var Uz=["municipality","municipalityKey","district","districtKey"],Cy=[..._y,...Uz],Dy={string:"text",email:"text",tel:"text",number:"number",date:"date",boolean:"boolean",consent:"boolean",enum:"option",address:"composite",docRef:"file",party:"edge",personRef:"edge",personList:"edge",roleKey:"roleKey",pricedItem:"pricedItem",pricedGroup:"pricedGroup",reduction:"reduction",article:"article",legalEntity:"legalEntity",contractGenerator:"contractGenerator",documentTemplate:"documentTemplate",localizedText:"localizedText"},Os=Object.keys(Dy);function _i(e){return typeof e=="string"&&e in Dy}s(_i,"isValueType");function xt(e){return e===void 0?void 0:Dy[e]}s(xt,"dataTypeOf");function Af(e,n){let t=xt(e),r=xt(n);return t!==void 0&&t===r}s(Af,"valueTypesCompatible");function Ef(e){return e===null?"null is not a text in both languages":xl(e,{type:"localizedText"})}s(Ef,"completeLocalizedTextIssue");function xl(e,n){if(Sf(n.type)&&!_i(n.type))return typeof e=="string"&&e.length>0?null:`${JSON.stringify(e)} is not a ${n.type} key`;let t=xt(n.type),r=JSON.stringify(e),i=`slot type "${n.type}" takes a binding, not a literal`;if(t===void 0||t==="composite"||t==="file"||t==="edge")return i;if(e===null)return null;switch(t){case"text":return typeof e=="string"?null:`${r} is not a text (slot type "${n.type}")`;case"date":return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e)?null:`${r} is not a date YYYY-MM-DD`;case"number":return typeof e=="number"&&Number.isFinite(e)?null:`${r} is not a number`;case"boolean":return typeof e=="boolean"?null:`${r} is not true/false`;case"option":{if(typeof e!="string")return`${r} is not an option value`;let o=(n.enumOptions??[]).map(a=>a.value);return o.length===0||o.includes(e)?null:`${r} is not one of the options ${o.join(", ")}`}case"pricedItem":{let o=e;return typeof o=="object"&&typeof o.itemKey=="string"&&o.itemKey.length>0&&Array.isArray(o.grantKeys)&&o.grantKeys.every(a=>typeof a=="string")?null:`${r} is not a priced item {"itemKey":\u2026,"grantKeys":[\u2026]}`}case"pricedGroup":return xO(e)?null:`${r} is not a priced group {"groupKey":\u2026,"grantKeys":[\u2026]}`;case"article":return typeof e=="string"&&e.length>0?null:`${r} is not an article key`;case"legalEntity":return typeof e=="string"&&e.length>0?null:`${r} is not a legal entity key`;case"contractGenerator":return ul(e)?null:`${r} is not a contract generator {"kind":"generator"|"package","key":\u2026,"revision"?:n}`;case"documentTemplate":return typeof e=="string"&&e.length>0?null:`${r} is not a document template key`;case"roleKey":return typeof e=="string"&&e.length>0?null:`${r} is not a role key`;case"localizedText":{let o=e,a=s(l=>typeof l=="string"&&l.trim().length>0,"filled");return typeof o=="object"&&Object.keys(o).sort().join(",")==="de,en"&&a(o.de)&&a(o.en)?null:`${r} is not a text in both languages {"de":\u2026,"en":\u2026}`}case"reduction":{let o=wo(e);return o===null?null:`${r} is not a reduction \u2014 ${o.en}`}}}s(xl,"literalTypeIssue");function AO(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(AO,"isObject");var Gz={collectPayment:{reason:"reason"}},zz={governedDocument:["mockAutoProduce"]},EO={collectPayment:{reason:{de:"`reason` gibt es als Knoteneigenschaft nicht mehr \u2014 der Hinweis f\xFCr die Familie ist der Eingang `inputs.reason` (ein fester Text auf Deutsch und Englisch im Parameter-Bereich).",en:"`reason` no longer exists as a node property \u2014 the note for the family is the input `inputs.reason` (a fixed text in German and English among the parameters)."}},governedDocument:{template:{de:"`template` gibt es am Knoten nicht mehr \u2014 die Parameter geh\xF6ren der Vorlage (ihr Datensatz, `plexus-cli catalog` documentTemplates[].parameters) und werden beim Speichern und Ver\xF6ffentlichen als `templateStamp` \xFCbernommen.",en:"`template` no longer exists on the node \u2014 the parameters belong to the template (its record, `plexus-cli catalog` documentTemplates[].parameters) and are stamped as `templateStamp` on save and publish."},cockpitFields:{de:'`cockpitFields` gibt es nicht mehr \u2014 ein Parameter, der im Cockpit erg\xE4nzt wird, ist sein Eingang `{ kind: "cockpit" }` (im Parameter-Bereich \u201Eim Cockpit erg\xE4nzen").',en:'`cockpitFields` no longer exists \u2014 a parameter completed in the cockpit is its input `{ kind: "cockpit" }` ("complete in the cockpit" among the parameters).'},mockAutoProduce:{de:"`mockAutoProduce` gibt es nicht mehr \u2014 das Muster-Dokument, das ein Upload-Knoten beim Eintritt selbst einstellte, ist entfernt; das Dokument kommt aus einem Upload.",en:"`mockAutoProduce` no longer exists \u2014 the sample document an upload node put on its slot by itself on entry is removed; the document comes from an upload."}}};function Fy(e){return Gz[String(e)]??{}}s(Fy,"movesOf");function TO(e){return zz[String(e)]??[]}s(TO,"deadOf");function $O(e){return AO(e)&&[...Object.keys(Fy(e.type)),...TO(e.type)].some(n=>n in e)}s($O,"oldShape");function RO(e){return(e?.nodes??[]).some($O)}s(RO,"needsNodeConfigInputMove");function Wz(e){return Ef(e)===null}s(Wz,"isCompleteText");function Yz(e){let n=AO(e.inputs)?{...e.inputs}:{},t={...e};for(let[r,i]of Object.entries(Fy(e.type)))if(r in e){if(i in n)return{unmoved:{nodeId:String(e.id),key:r,reason:"inputExists"}};if(!Wz(e[r]))return{unmoved:{nodeId:String(e.id),key:r,reason:"valueNotLocalized"}};n[i]={kind:"literal",value:e[r]},delete t[r]}for(let r of TO(e.type))delete t[r];return Object.keys(Fy(e.type)).some(r=>r in e)&&(t.inputs=n),{node:t}}s(Yz,"moveNode");function IO(e){let n=[],t=[],r=e.nodes.map(i=>{if(!$O(i))return i;let o=Yz(i);return"unmoved"in o?(t.push(o.unmoved),i):(n.push(String(i.id)),o.node)});return n.length===0?{graph:e,moved:n,unmoved:t}:{graph:{...e,nodes:r},moved:n,unmoved:t}}s(IO,"moveNodeConfigToInputs");var Ly="collectPayment",Ps=["online","separate"];function Tf(e){return Ps.includes(e)}s(Tf,"isCollectPaymentSettlement");var Ns="paid",My="skipPayment",Ci="article",Ht="settlement",Di="reason",Jt="payee",qy=["one_time"];function $f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s($f,"isObject");function OO(e){if(!$f(e)||e.type!==Ly)return!1;let n=$f(e.inputs)?e.inputs:{},t=n[Ht];return!$f(t)||t.kind!=="literal"||t.value!=="online"?!1:!(Jt in n)}s(OO,"isOnlinePaymentWithoutPayee");function PO(e){return(e?.nodes??[]).some(OO)}s(PO,"needsPayee");function NO(e,n={}){let t=[],r=[],i=e.nodes.map(o=>{if(!OO(o))return o;let a=String(o.id),l=Object.hasOwn(n,a)?n[a]:void 0;if(l===void 0||l==="")return r.push(a),o;t.push({nodeId:a,payee:l});let d=$f(o.inputs)?o.inputs:{};return{...o,inputs:{...d,[Jt]:{kind:"literal",value:l}}}});return t.length===0?{graph:e,set:t,refused:r}:{graph:{...e,nodes:i},set:t,refused:r}}s(NO,"setPayeeOnOnlinePayments");function Rf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Rf,"isObject");function Ky(e){return Rf(e)&&Rf(e.assign)&&"userId"in e.assign}s(Ky,"namesUser");function If(e){return(e?.nodes??[]).flatMap(n=>Rf(n)&&Array.isArray(n.tasks)?n.tasks.filter(Ky).map(t=>({nodeId:String(n.id),taskKey:String(t.key),hasTeam:typeof t.assign.group=="string"&&t.assign.group.length>0})):[])}s(If,"taskUserAssignments");function _O(e){let n=If(e);if(n.length===0)return{graph:e,dropped:n};let t=e.nodes.map(r=>{if(!Rf(r)||!Array.isArray(r.tasks)||!r.tasks.some(Ky))return r;let i=r.tasks.map(o=>{if(!Ky(o))return o;let{userId:a,...l}=o.assign,{assign:d,...c}=o;return Object.keys(l).length===0?c:{...c,assign:l}});return{...r,tasks:i}});return{graph:{...e,nodes:t},dropped:n}}s(_O,"dropTaskAssignUserIds");var _s={"assign{}":{kind:"team",codec:"key",involves:!0,required:!1,what:{de:"Team der Knoten-Aufgabe",en:"team of the node task"},consequence:{de:"beim Betreten des Knotens entsteht die Aufgabe f\xFCr niemanden",en:"entering the node creates the task for nobody"}},"actionTeams{}":{kind:"team",codec:"key",involves:!1,required:!1,what:{de:"Team, das die Knoten-Aktion ausf\xFChren darf",en:"team that may perform the node action"},consequence:{de:"au\xDFer der zust\xE4ndigen Person darf niemand die Aktion ausf\xFChren",en:"nobody but the responsible person may perform the action"}},"tasks[].assign.group":{kind:"team",codec:"key",involves:!0,required:!0,what:{de:"Team der Aufgabe",en:"team of the task"},consequence:{de:"die Aufgabe kann nicht angelegt werden, und der Prozess bleibt stehen",en:"the task cannot be created and the process stops"}},"tasks[].params.revisionGroup":{kind:"team",codec:"key",involves:!0,required:!1,what:{de:"Team der \xDCberarbeitung",en:"revision team"},consequence:{de:"eine Ablehnung findet niemanden, der \xFCberarbeitet",en:"a rejection finds nobody to revise"}},"tasks[].result.chat":{kind:"team",codec:"chatTarget",involves:!1,required:!1,what:{de:"Chat des Ergebnisses",en:"chat of the result"},consequence:{de:"das Ergebnis l\xE4sst sich nicht im Chat ablegen",en:"the result cannot be posted to the chat"}},"optionalActions[].trigger":{kind:"team",codec:"key",involves:!1,required:!1,what:{de:"Team, das die Aktion ausl\xF6sen darf",en:"team that may trigger the action"},consequence:{de:"niemand au\xDFer der Prozessverantwortung kann die Aktion ausl\xF6sen",en:"nobody but the process owner can trigger the action"}}},jy=s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null,"record");function CO(e,n){if(typeof n!="string"||n.length===0)return null;if(e==="key")return n;let t=As(n);return t?.kind==="team"?t.groupKey:null}s(CO,"decodeKey");var DO={"assign{}":"assign","actionTeams{}":"actionTeams"},Hz=s(e=>e in DO,"isMapLeaf");function Jz(e){let n=/^(tasks|optionalActions)\[\](?:\.([a-zA-Z]+))?\.([a-zA-Z]+)$/.exec(e);return n===null&&F(`[resource] unreadable reference leaf "${e}"`),{list:n[1],field:n[2]??null,key:n[3]}}s(Jz,"locate");function Of(e){let n=[],t=e;for(let[r,i]of Object.entries(DO))for(let[o,a]of Object.entries(jy(t[i])??{}))n.push({path:`${i}.${o}`,leaf:r,owner:o,key:CO("key",a),missing:typeof a!="string"||a.length===0});for(let r of Object.keys(_s)){if(Hz(r))continue;let i=_s[r],{list:o,field:a,key:l}=Jz(r);for(let d of Array.isArray(t[o])?t[o]:[]){let c=jy(d);if(c===null||typeof c.key!="string")continue;let p=(a===null?c:jy(c[a]))?.[l];if(p===void 0&&!i.required)continue;let m=typeof p!="string"||p.length===0;n.push({path:`${o}.${c.key}${a===null?"":`.${a}`}.${l}`,leaf:r,owner:c.key,key:CO(i.codec,p),missing:m})}}return n}s(Of,"nodeResourceReferences");var FO=s(e=>(e??[]).map(n=>`\u201E${n}\u201C`).join(", "),"list"),LO=s(e=>(e??[]).map(n=>`"${n}"`).join(", "),"listEn"),Qz={"address/shape":{de:s(e=>({problem:`${e.where}: \u201E${e.address}\u201C ist keine g\xFCltige Adresse.`,remedy:"W\xE4hle die Adresse in der Auswahl neu."}),"de"),en:s(e=>({problem:`${e.where}: "${e.address}" is not a valid address.`,remedy:"Choose the address again from the picker."}),"en")},"address/missing":{de:s(e=>({problem:`${e.where}: Hier fehlt die Adresse, ohne die dieser Schritt nicht arbeiten kann.`,remedy:"W\xE4hle sie in der Auswahl."}),"de"),en:s(e=>({problem:`${e.where}: The address this step cannot work without is missing.`,remedy:"Choose it from the picker."}),"en")},"address/bareIdentifier":{de:s(e=>({problem:`${e.where}: \u201E${e.address}\u201C nennt nur einen Schl\xFCssel, nicht, wer ihn erzeugt.`,remedy:"W\xE4hle in der Auswahl die volle Adresse, z. B. das Feld aus dem Formular, das es erfasst."}),"de"),en:s(e=>({problem:`${e.where}: "${e.address}" names a key only, not who produces it.`,remedy:"Choose the full address from the picker, e.g. the field from the form that collects it."}),"en")},"address/unknownOwner":{de:s(e=>({problem:`${e.where}: ${e.address} nennt einen Knoten oder eine Aufgabe, die es im Ablauf nicht gibt.`,remedy:"W\xE4hle eine Adresse aus der Auswahl."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} names a node or task the workflow does not have.`,remedy:"Choose an address from the picker."}),"en")},"address/unknownKey":{de:s(e=>({problem:`${e.where}: ${e.producer??"der Erzeuger"} erzeugt ${e.address} nicht.`,remedy:"W\xE4hle einen Wert, den der Erzeuger tats\xE4chlich liefert."}),"de"),en:s(e=>({problem:`${e.where}: ${e.producer??"the producer"} does not produce ${e.address}.`,remedy:"Choose a value the producer actually delivers."}),"en")},"address/envCohortBound":{de:s(e=>({problem:`${e.where}: ${e.address} \xE4ndert sich, wenn Stufe oder Schuljahr gewechselt werden \u2014 ein Dokument, das den Wert druckt, w\xFCrde das nicht bemerken.`,remedy:"Lies den Wert \xFCber ein Formularfeld, das ihn berechnet (z. B. \u201EKlassenstufe\u201C): ein Wechsel friert es neu ein und h\xE4lt ein gedrucktes Dokument an."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} changes when the application's stage or school year is changed \u2014 a document printing it would not notice.`,remedy:'Read it through a form field that computes it (e.g. "Grade"): a change re-freezes it and holds a printed document.'}),"en")},"address/staffInputConditionOnly":{de:s(e=>({problem:`${e.where}: ${e.address} ist eine interne Angabe beim Anlegen \u2014 sie lenkt eine Weiche (\u201EWenn\u201C-Knoten) oder f\xFCllt einen Parameter eines Knotens.`,remedy:"Lies sie in der Bedingung eines \u201EWenn\u201C-Knotens oder binde einen Parameter des Knotens daran (z. B. im Vertrag); Formulare, Aufgaben und Regeln lesen sie nicht."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} is a staff input set at the start \u2014 it steers a branch (an "If" node) or fills a node's parameter.`,remedy:'Read it in the condition of an "If" node or bind a node parameter to it (e.g. in the contract); forms, tasks and rules do not read it.'}),"en")},"address/ownerNotWriter":{de:s(e=>({problem:`${e.where}: Die Aufgabe \u201E${e.producer}\u201C schreibt ${e.address} nicht.`,remedy:"W\xE4hle den Wert \xFCber seinen Schl\xFCssel; die schreibende Aufgabe folgt daraus."}),"de"),en:s(e=>({problem:`${e.where}: The task "${e.producer}" does not write ${e.address}.`,remedy:"Choose the value by its key; the writing task follows from it."}),"en")},"address/taskOwnerTaken":{de:s(e=>({problem:`${e.where}: Den Aufgaben-Schl\xFCssel gibt es mehrfach (${FO(e.names)}), und eine dieser Aufgaben schreibt Prozesswerte.`,remedy:"Gib der schreibenden Aufgabe einen Schl\xFCssel, den keine andere Aufgabe tr\xE4gt."}),"de"),en:s(e=>({problem:`${e.where}: The task key is used more than once (${LO(e.names)}), and one of these tasks writes process values.`,remedy:"Give the writing task a key no other task carries."}),"en")},"address/notVisible":{de:s(e=>({problem:e.producerNode!==void 0&&e.producerNode!==e.producer?`${e.where}: ${e.address} \u2014 \u201E${e.producer}\u201C h\xE4ngt an \u201E${e.producerNode}\u201C, das nicht auf jedem Weg vor \u201E${e.reader}\u201C liegt.`:`${e.where}: ${e.address} \u2014 \u201E${e.producer}\u201C liegt nicht auf jedem Weg vor \u201E${e.reader}\u201C.`,remedy:`Lies nur, was auf jedem Weg vor \u201E${e.reader}\u201C entsteht, oder ordne die Schritte so, dass der Erzeuger immer vorher l\xE4uft.`}),"de"),en:s(e=>({problem:e.producerNode!==void 0&&e.producerNode!==e.producer?`${e.where}: ${e.address} \u2014 "${e.producer}" hangs on "${e.producerNode}", which does not lie before "${e.reader}" on every path.`:`${e.where}: ${e.address} \u2014 "${e.producer}" does not lie before "${e.reader}" on every path.`,remedy:`Read only what is produced before "${e.reader}" on every path, or order the steps so the producer always runs first.`}),"en")},"address/pathNotInTarget":{de:s(e=>({problem:`${e.where}: ${e.address} \u2014 ${e.producer??"der Erzeuger"} hat dieses Feld nicht.`,remedy:"W\xE4hle ein Feld, das es dort gibt."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} \u2014 ${e.producer??"the producer"} has no such field.`,remedy:"Choose a field that exists there."}),"en")},"address/typeMismatch":{de:s(e=>({problem:`${e.where}: erwartet ${e.expected}, ${e.address} ist ${e.actual}.`,remedy:`W\xE4hle einen Wert vom Typ ${e.expected}.`}),"de"),en:s(e=>({problem:`${e.where}: expects ${e.expected}, ${e.address} is ${e.actual}.`,remedy:`Choose a value of type ${e.expected}.`}),"en")},"address/notFormInstance":{de:s(e=>({problem:`${e.where}: ${e.address} ist kein ganzes Formular.`,remedy:"W\xE4hle das Formular des Knotens, der es anlegt \u2014 ohne Feld, nicht den Knoten, der es \xFCbernimmt."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} is not a whole form.`,remedy:"Choose the form of the node that creates it \u2014 without a field, not the node that continues it."}),"en")},"address/mixedForms":{de:s(e=>({problem:`${e.where}: Die Liste liest Felder aus mehreren Formularen (${FO(e.names)}), beurteilt wird sie aber an einem Formular.`,remedy:"W\xE4hle alle Felder dieser Liste aus demselben Formular."}),"de"),en:s(e=>({problem:`${e.where}: The list reads fields of several forms (${LO(e.names)}) but is judged on one.`,remedy:"Choose every field of this list from the same form."}),"en")},"workItems/keyFormat":{de:s(e=>({problem:`${e.where}: Der Aufgaben-Schl\xFCssel \u201E${e.address}\u201C hat nicht die Form ^[a-z][a-zA-Z0-9_]*$.`,remedy:"Benenne die Aufgabe in camelCase um, z. B. \u201EgeschwisterRang\u201C."}),"de"),en:s(e=>({problem:`${e.where}: The task key "${e.address}" does not match ^[a-z][a-zA-Z0-9_]*$.`,remedy:'Rename the task in camelCase, e.g. "siblingRank".'}),"en")}};function Cs(e,n,t){let{problem:r,remedy:i}=Qz[e][t](n);return`[${e}] ${r} ${i}`}s(Cs,"addressMessage");function Qt(e){let n=[];for(let t of e){let r=t.next;if(r)for(let[i,o]of Object.entries(r))n.push({id:`${t.id}|${i}`,source:t.id,target:o.to,sourceBranchId:i})}return n}s(Qt,"derivedEdges");function By(e){let n=new Map;for(let t of Qt(e.nodes)){let r=n.get(t.source)??[];r.push(t.target),n.set(t.source,r)}return n}s(By,"successorsOf");function Pf(e,n,t){if(n===t)return!0;let r=By(e),i=new Set([...r.values()].flat()),o=e.nodes.filter(l=>!i.has(l.id)&&l.id!==n).map(l=>l.id),a=new Set(o);for(;o.length>0;){let l=o.shift();if(l===t)return!1;for(let d of r.get(l)??[])d===n||a.has(d)||(a.add(d),o.push(d))}return!0}s(Pf,"dominates");function MO(e,n,t){if(n===t)return!0;let r=By(e),i=[n],o=new Set(i);for(;i.length>0;){let a=i.shift();for(let l of r.get(a)??[]){if(l===t)return!0;o.has(l)||(o.add(l),i.push(l))}}return!1}s(MO,"reaches");function qO(e,n,t,r){let i=new Map(e.nodes.map(d=>[d.id,d])),o=By(e),a=[n],l=new Set(a);for(;a.length>0;){let d=a.shift();for(let c of o.get(d)??[]){if(l.has(c)||t.has(c))continue;l.add(c);let u=i.get(c);if(u!==void 0&&r(u))return c;a.push(c)}}return null}s(qO,"reachedAvoiding");function Vy(e,n){let t=[],r=s(a=>({address:a.address,type:a.type,...a.label!==void 0?{label:a.label}:{},nodeId:a.nodeId}),"toVisible");for(let a of e.nodes)if(Pf(e,a.id,n))for(let l of Dr(e,a))t.push(r(l));for(let a of ZI)t.push({address:{scope:"env",key:a},type:Ay(a),label:Ey(a),nodeId:null});for(let a of af(e))t.push({address:{scope:"env",key:lf(a.key)},type:a.type,label:a.label,nodeId:null});let i=new Set(t.map(a=>se(a.address))),o=(Array.isArray(e.processStore)?e.processStore:[]).filter(a=>a.derive!==void 0);for(let a=!0;a;){a=!1;for(let l of o){let d=se({scope:"derived",key:l.key});if(i.has(d))continue;let c=yl(e,l.key);c===null||!c.every(u=>i.has(se(kf(u))))||(t.push({address:{scope:"derived",key:l.key},type:l.type,label:l.label,nodeId:null}),i.add(d),a=!0)}}return t}s(Vy,"visibleAddressesAt");function oi(e,n){let t=e?.readinessFormFieldsByFormNode?.get(n.owner);if(t!==void 0)return t.get(n.path)??null}s(oi,"formFieldEntryOf");var KO={binding:{de:"Eingang",en:"Input"},condition:{de:"Bedingung",en:"Condition"},nodeReads:{de:"Gelesene Felder",en:"Fields read"},requires:{de:"Geforderte Felder",en:"Required fields"},adoptForm:{de:"\xDCbernommenes Formular",en:"Continued form"},setFlagTarget:{de:"Freizuschaltendes Formular",en:"Form to unlock"},form:{de:"Formular",en:"Form"},contract:{de:"Vertrag",en:"Contract"},payment:{de:"Zahlung",en:"Payment"},taskWhen:{de:"Bedingung",en:"Condition"},optionalActionWhen:{de:"Bedingung der optionalen Aktion",en:"Condition of the optional action"},taskReads:{de:"Gelesene Felder der Aufgabe",en:"Fields the task reads"},taskDocument:{de:"Dokumente",en:"Documents"},familyRequestFields:{de:"Nachforderbare Felder",en:"Requestable fields"},familyRequestFrom:{de:"Nachforderung aus",en:"Request from"},suggest:{de:"Vorschlag",en:"Suggestion"},reduction:{de:"Erm\xE4\xDFigung des Preises",en:"Reduction of the price"},pricingRule:{de:"Preisregel",en:"Pricing rule"}},Zz=new Set(["nodeReads","requires","taskReads","taskDocument","familyRequestFields"]);function Xz(e,n,t){let r=[];n.taskKey!==void 0&&r.push(`${t==="de"?"Aufgabe":"task"} \u201E${vo(e,n.taskKey,t)}\u201C`);let i=n.kind==="binding"?` \u201E${n.at.split(".").pop()}\u201C`:"";return r.push(`${KO[n.kind][t]}${i}`),r.join(" \u203A ")}s(Xz,"addressFieldWhere");function Sl(e,n,t){let r=Xz(e,n,t);return n.nodeId===null?r:`\u201E${Oe(e,n.nodeId,t)}\u201C \u203A ${r}`}s(Sl,"whereOf");function jO(e,n,t){if(n.scope==="node")return Oe(e,n.owner,t);if(n.scope==="task")return vo(e,n.owner,t)}s(jO,"producerName");function BO(e,n){let t=[],r=new Set,i=s((l,d,c)=>{let u={de:Cs(l,c("de"),"de"),en:Cs(l,c("en"),"en")},p=`${d}|${u.de}`;r.has(p)||(r.add(p),t.push({layer:"GRAPH",kind:"nodeRule",path:d,reason:u,severity:"error"}))},"report"),o=new Map(e.nodes.map(l=>[l.id,l])),a=[...e.nodes.flatMap(l=>kl(l)),...bf(e)];for(let l of a){let d=s(c=>Sl(e,l,c),"where");for(let c of eW(e,l,i))tW(e,l,c,i)&&(iW(e,l,c,n,i),$y.has(l.kind)&&!sW(o,c)&&i("address/notFormInstance",l.at,u=>({where:d(u),address:Ve(e,c,u)})))}return aW(e,i),lW(e,a,i),fW(e,i),mW(e,i),t}s(BO,"checkAddresses");function eW(e,n,t){let r=s(i=>Sl(e,n,i),"where");if(Ry(n)){let i=vf(n.value)??[];for(let o of i)o.address===null&&t(o.reason==="bareIdentifier"?"address/bareIdentifier":"address/shape",n.at,a=>({where:r(a),address:o.identifier}));return Rs(n)}return typeof n.value=="string"?(t("address/bareIdentifier",n.at,i=>({where:r(i),address:n.value})),[]):we(n.value)?[n.value]:(t("address/shape",n.at,i=>({where:r(i),address:JSON.stringify(n.value)??"undefined"})),[])}s(eW,"checkFieldShape");function VO(e,n,t,r){let i=jO(e,t,r);return{where:Sl(e,n,r),address:Ve(e,t,r),...i!==void 0?{producer:i}:{}}}s(VO,"addressParams");function nW(e,n,t){return Sy(n)||t==="optionalActionWhen"&&(ks(e,n)!==void 0||Wt(n))?null:ks(e,n)!==void 0?t==="condition"||t==="binding"?null:"address/staffInputConditionOnly":Wt(n)?"address/envCohortBound":"address/unknownKey"}s(nW,"envAddressRefusal");function tW(e,n,t,r){let i=s(o=>VO(e,n,t,o),"params");switch(t.scope){case"env":{let o=nW(e,t.key,n.kind);return o===null?!0:(r(o,n.at,i),!1)}case"derived":return(e.processStore??[]).find(a=>a.key===t.key)?.derive!==void 0?!0:(r("address/unknownKey",n.at,i),!1);case"task":return e.nodes.some(a=>(a.tasks??[]).some(l=>l.key===t.owner))?(e.processStore??[]).some(a=>a.key===t.key&&a.derive===void 0)?Fr(e,t.owner,t.key)===null?(r("address/ownerNotWriter",n.at,i),!1):!0:(r("address/unknownKey",n.at,i),!1):(r("address/unknownOwner",n.at,i),!1);case"node":{let o=e.nodes.find(a=>a.id===t.owner);return o===void 0?(r("address/unknownOwner",n.at,i),!1):Dr(e,o).some(a=>a.address.scope==="node"&&a.address.key===t.key)?!0:(r($y.has(n.kind)&&vt(o)?"address/notFormInstance":"address/unknownKey",n.at,i),!1)}}}s(tW,"resolves");function rW(e,n){return e===void 0||n===void 0||xt(n)===void 0?!0:xt(e)!==void 0&&Af(e,n)}s(rW,"addressTypeFits");function iW(e,n,t,r,i){let o=s(l=>VO(e,n,t,l),"params");if(t.scope!=="env"&&t.path!==void 0&&!oW(e,n,t,r)){i("address/pathNotInTarget",n.at,o);return}if(n.expectedType===void 0)return;let a=Oy(e,t);rW(a,n.expectedType)||i("address/typeMismatch",n.at,l=>({...o(l),expected:n.expectedType,actual:a}))}s(iW,"checkPathAndType");function oW(e,n,t,r){if(t.scope!=="node")return!1;if(Oy(e,t)!==void 0)return!0;if(t.key!==it)return!1;if(!Zz.has(n.kind))return e.nodes.find(o=>o.id===t.owner)?.formExports===void 0;let i=r?.readinessFormFieldsByFormNode?.get(t.owner);return i===void 0||i.has(t.path)}s(oW,"pathExists");function sW(e,n){if(!wr(n))return!1;let t=e.get(n.owner);return t!==void 0&&t.type==="form"&&!vt(t)}s(sW,"isCreatingFormInstance");function aW(e,n){for(let t of e.nodes){let r=new Set(kl(t).map(i=>i.kind));for(let i of tO(t))r.has(i)||n("address/missing",`nodes.${t.id}.${i}`,o=>({where:`\u201E${Oe(e,t.id,o)}\u201C \u203A ${KO[i][o]}`}))}}s(aW,"checkRequiredFields");function lW(e,n,t){let r=new Map;for(let i of n)if(i.judgedTogether!==null)for(let o of Rs(i)){if(o.scope!=="node"||o.key!==it)continue;let a=r.get(i.judgedTogether)??[];a.push({field:i,owner:o.owner}),r.set(i.judgedTogether,a)}for(let[i,o]of r){let a=[...new Set(o.map(l=>l.owner))];a.length<2||t("address/mixedForms",i,l=>({where:Sl(e,o[0].field,l),names:a.map(d=>Oe(e,d,l))}))}}s(lW,"checkMixedForms");function dW(e,n){return e.type==="engagePush"&&n.kind==="payment"}s(dW,"readSkipsAbsentProducer");function cW(e,n,t){return n!==t&&MO(e,n,t)}s(cW,"precedesOnSomePath");function uW(e,n,t,r){let i=kf(t.address);return r.has(se(i))||!pW(e,i)?!0:t.origin==="written"&&i.scope==="node"&&dW(n,t.field)&&cW(e,i.owner,n.id)}s(uW,"readPassesVisibility");function fW(e,n){for(let t of e.nodes){let r=bo(e,t);if(r.length===0)continue;let i=new Set(Vy(e,t.id).map(o=>se(o.address)));for(let o of r){let a=kf(o.address);if(uW(e,t,o,i))continue;let l=a.scope==="task"?Fr(e,a.owner,a.key):a.scope==="node"?a.owner:null;n("address/notVisible",o.field.at,d=>({where:Sl(e,o.field,d),address:Ve(e,o.address,d),producer:jO(e,a,d)??Ve(e,a,d),...l!==null?{producerNode:Oe(e,l,d)}:{},reader:Oe(e,t.id,d)}))}}}s(fW,"checkVisibility");function pW(e,n){if(n.scope==="env")return Sy(n.key);if(n.scope==="derived")return yl(e,n.key)!==null;let t=se(n);return e.nodes.some(r=>Dr(e,r).some(i=>se(i.address)===t))}s(pW,"producedSomewhere");function mW(e,n){let t=new Map;for(let r of e.nodes){let i=new Set(Dr(e,r).flatMap(o=>o.address.scope==="task"?[o.address.owner]:[]));for(let[o,a]of(r.tasks??[]).entries()){let l=a.key;if(typeof l!="string"||!Cr.test(l)){n("workItems/keyFormat",`nodes.${r.id}.tasks.${o}.key`,c=>({where:`\u201E${Oe(e,r.id,c)}\u201C`,address:String(l)}));continue}let d=t.get(l)??[];d.push({nodeId:r.id,writes:i.has(l)}),t.set(l,d)}}for(let[r,i]of t)if(!(i.length<2||!i.some(o=>o.writes)))for(let o of i)n("address/taskOwnerTaken",`nodes.${o.nodeId}.tasks.${r}`,a=>({where:`\u201E${Oe(e,o.nodeId,a)}\u201C \u203A ${a==="de"?"Aufgabe":"task"} \u201E${vo(e,r,a)}\u201C`,names:i.map(l=>Oe(e,l.nodeId,a))}))}s(mW,"checkTaskKeys");function Nf(e,n){return e.label[n]??""}s(Nf,"wordingIn");function Fi(e,n){let t=UO(e,n),r=Nf(e.qualifier,n);return t===""||r===""&&Nf(e.qualifier,"de")!==""?"":r===""?t:`${r} \xB7 ${t}`}s(Fi,"fieldLabelIn");function UO(e,n){return Nf(e,n)}s(UO,"fieldOwnLabelIn");function Ds(e){return{key:e.key,kind:e.kind,type:e.kind==="entered"?e.type:null,repeated:e.kind==="entered"&&e.repeated,reviewRequired:e.kind==="entered"&&e.reviewRequired,name:{de:Fi(e,"de"),en:Fi(e,"en")}}}s(Ds,"catalogField");function Fs(e,n){switch(e){case"nodeReads":return n.repeated?"repeated":null;case"requires":return n.repeated?"repeated":n.kind==="computed"?"computed":n.name.en===""?"untranslated":null;case"taskDocument":return n.repeated?"repeated":n.kind==="entered"&&n.type==="docRef"?null:"notDocument";case"taskReads":case"familyRequestFields":return null}}s(Fs,"catalogFieldRefusal");function _f(e,n){let t=e.buses.find(r=>r.key===n);return t||F(`[progress] layout '${e.id}' has no bus '${n}'`),t}s(_f,"progressBus");function Al(e,n){return e.states.some(t=>t.id===n)}s(Al,"isBusState");function GO(e,n){let t=e.terminalSemantics?.[n];return t||F(`[progress] no terminal semantics for state '${n}' on bus '${e.key}'`),t}s(GO,"terminalSemantics");function Cf(e,n){return!!e.terminalSemantics&&Object.prototype.hasOwnProperty.call(e.terminalSemantics,n)}s(Cf,"hasTerminalSemantics");function hW(e,n){return(e.boards??[]).find(t=>t.audience===n||t.audience==="both")??null}s(hW,"boardForAudience");function zO(e){return hW(_f(e,"process"),"internal")}s(zO,"internalProcessBoard");function Ls(e,n,t){let r=null;for(let i of e.mappings)if(i.event===t)if("nodeId"in i.match){if(i.match.nodeId===n.id)return{bus:i.bus,state:i.state}}else i.match.nodeType===n.type&&(r=i);return r?{bus:r.bus,state:r.state}:null}s(Ls,"resolveProgressEvent");var Ms={approved:"enrolled",rejected:"declined",withdrawn:"declined",expired:"declined"},si=Object.keys(Ms);function xo(e){return Object.hasOwn(Ms,e)}s(xo,"isEndNodeOutcome");var Uy={approved:{de:"Angenommen",en:"Admitted"},rejected:{de:"Abgelehnt",en:"Rejected"},withdrawn:{de:"Zur\xFCckgezogen",en:"Withdrawn"},expired:{de:"Abgelaufen",en:"Expired"}};var Li=["commit","discard"],Zce=w.union(...Li.map(e=>w.literal(e)));function Df(e){return typeof e=="string"&&Li.includes(e)}s(Df,"isApplicationDataDecision");function Mn(e){return Object.keys(e)}s(Mn,"progressEventsOf");var te=s((e,n)=>({de:e,en:n}),"lt"),en=s((e,n,t,r,i=null,o=null)=>({chipLabel:e,tone:n,nextAction:i,affordance:o,title:t,body:r}),"ex"),WO={key:"eingeschrieben",label:te("Eingeschrieben","Enrolled"),scope:"global",defaultCollapsed:!0},Ff={key:"abgesagt",label:te("Abgesagt","Declined"),scope:"global",track:"exit",defaultCollapsed:!0},YO={key:"abgelehnt",label:te("Abgelehnt","Rejected"),scope:"global",track:"exit",defaultCollapsed:!0};var HO={enrolled:{label:te("Eingeschrieben","Enrolled"),tone:"green",terminal:{lifecycleStatus:"completed",outcome:"approved"},phase:WO,external:en(te("Eingeschrieben","Enrolled"),"green",te("Sie sind eingeschrieben!","You are enrolled!"),te("Ihre Anmeldung ist abgeschlossen und Ihr Platz ist gesichert. Wir freuen uns auf Sie.","Your enrolment is complete and your place is secured. We look forward to welcoming you."))},declined:{label:te("Abgesagt","Declined"),tone:"red",terminal:{lifecycleStatus:"completed",outcome:"rejected"},phase:Ff,external:en(te("Abgesagt","Declined"),"red",te("Die Bewerbung wurde beendet","The application has ended"),te("Ihre Bewerbung wurde nicht fortgef\xFChrt.","Your application was not continued."))}},JO={role:"effect",effect:"pure",progressDefaults:HO,progressEvents:Mn(HO),inputs:s(()=>[{id:"applicationOutcome",label:{de:"Ergebnis",en:"Outcome"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:si.map(e=>({value:e,label:Uy[e]}))},{id:"dataDecision",label:{de:"Erfasste Daten",en:"Captured data"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:[{value:"commit",label:{de:"\xDCbernehmen",en:"Keep"}},{value:"discard",label:{de:"Verwerfen",en:"Discard"}}]}],"inputs"),notificationEvents:s(()=>[{id:"reached",label:{de:"Verfahren abgeschlossen",en:"Process completed"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"outcome",type:"string",required:!0}]}],"notificationEvents"),validate:s(e=>[...gW(e),...yW(e),...wW(e)],"validate")},qs=s((e,n,t,r)=>({layer:"GRAPH",kind:"nodeRule",path:`node.${e.id}.inputs.${n}`,reason:{de:t,en:r},severity:"error"}),"nodeIssue");function So(e){let n=e.inputs?.applicationOutcome;return n?.kind==="literal"&&n.value!=null?String(n.value):null}s(So,"literalOutcome");function gW(e){if(e.type!=="end")return[];let n=e.inputs?.applicationOutcome;if(n===void 0||n.kind==="unset")return[];let t=So(e);return t===null?[qs(e,"applicationOutcome",`[end/applicationOutcome] ${e.label.de}: das Ergebnis ist kein fester Wert \u2014 die Engine kann den Abschluss nicht ableiten`,`[end/applicationOutcome] ${e.label.en}: the application outcome is no fixed value \u2014 the engine cannot derive the terminal`)]:xo(t)?[]:[qs(e,"applicationOutcome",`[end/applicationOutcome] ${e.label.de}: '${t}' ist kein Ausgang eines Endknotens (${si.join("|")}) \u2014 die Warteliste endet \xFCber das closed-Outcome ihres Wartelistenknotens`,`[end/applicationOutcome] ${e.label.en}: '${t}' is not an outcome of an end node (${si.join("|")}) \u2014 the waitlist ends through the closed outcome of its waitlist node`)]}s(gW,"checkEndApplicationOutcome");function yW(e){if(e.type!=="end")return[];let n=e.inputs?.dataDecision;return!n||n.kind!=="literal"||n.value==null?[qs(e,"dataDecision",`[end/dataDecision] ${e.label.de}: dataDecision fehlt \u2014 der Endknoten muss festlegen, ob die erfassten Daten \xFCbernommen (commit) oder verworfen (discard) werden`,`[end/dataDecision] ${e.label.en}: dataDecision is missing \u2014 the end node must decide whether the collected data is kept (commit) or discarded (discard)`)]:Df(n.value)?[]:[qs(e,"dataDecision",`[end/dataDecision] ${e.label.de}: dataDecision '${String(n.value)}' ist ung\xFCltig (${Li.join("|")})`,`[end/dataDecision] ${e.label.en}: dataDecision '${String(n.value)}' is invalid (${Li.join("|")})`)]}s(yW,"checkEndDataDecision");function wW(e){if(e.type!=="end")return[];let n=So(e);if(n===null||!xo(n)||n==="approved")return[];let t=e.inputs?.dataDecision;if(t?.kind!=="literal"||t.value!=="commit")return[];let r=Uy[n];return[{...qs(e,"dataDecision",`[end/commitWithoutApproval] ${e.label.de}: Ende ohne Zusage \xFCbernimmt die erfassten Daten (commit) \u2014 Personen und Beziehungen bleiben nach dem Ergebnis \u201E${r.de}" bestehen. Gewollt? Sonst discard.`,`[end/commitWithoutApproval] ${e.label.en}: end without admission keeps the captured data (commit) \u2014 persons and relationships remain after the outcome "${r.en}". Intended? Otherwise discard.`),severity:"warning"}]}s(wW,"checkEndCommitWithoutApproval");function QO(e,n){if(!n?.layout||!n.wiring)return[];let t=[];for(let r of e.nodes){if(r.type!=="end")continue;let i=So(r);if(i===null||!xo(i))continue;let o=Ms[i],a=Ls(n.wiring,r,o);if(a===null)continue;let l=n.layout.buses.find(c=>c.key===a.bus);if(l===void 0||!Cf(l,a.state))continue;let d=GO(l,a.state).outcome;d!==i&&t.push(qs(r,"applicationOutcome",`[end/outcomeMismatch] ${r.label.de}: das Ergebnis \u201E${i}" passt nicht zum Endzustand \u201E${a.state}" (Bus ${a.bus}), der \u201E${String(d)}" besiegelt \u2014 Ergebnis oder Verdrahtung angleichen.`,`[end/outcomeMismatch] ${r.label.en}: the outcome "${i}" does not match the final state "${a.state}" (bus ${a.bus}), which seals "${String(d)}" \u2014 align the outcome or the wiring.`))}return t}s(QO,"checkEndOutcomeMatchesTerminal");function Ks(e){let n=He(e);return typeof n.inputs=="function"?n.inputs(e):[]}s(Ks,"inputSlots");function kW(e,n){return Ks(e).find(t=>t.id===n)}s(kW,"findInputSlot");function bW(e,n){let t=kW(e,n);if(!t)return{source:"missing",spec:{id:n,label:{de:n,en:n},type:"string"},unknownSlot:!0};let r=e.inputs?.[n]??{kind:"unset"};return r.kind==="binding"&&we(r.address)?{source:"binding",spec:t,address:r.address}:r.kind==="literal"?{source:"literal",spec:t,value:r.value}:r.kind==="cockpit"&&t.deferrable===!0?{source:"cockpit",spec:t}:t.defaultValue!==void 0?{source:"default",spec:t,value:t.defaultValue}:t.required?{source:"missing",spec:t}:{source:"optional",spec:t}}s(bW,"resolveInput");function ZO(e){return Ks(e).filter(n=>bW(e,n.id).source==="missing")}s(ZO,"missingRequiredInputs");var vW=["personRef","formRef","documentRef","docRef"];function xW(e){let n=He(e);return typeof n.inputs!="function"?[]:n.inputs(e).map(t=>({id:t.id,type:t.type}))}s(xW,"listInputs");function XO(e){let n=[];for(let t of e.nodes)for(let r of xW(t))!vW.includes(r.type)||t.inputs?.[r.id]?.kind!=="literal"||n.push({layer:"GRAPH",kind:"modelError",path:`node.${t.id}.param.${r.id}`,reason:{de:`${t.label.de}: Literal f\xFCr referenztypisierten Slot "${r.id}" ist verboten \u2014 der Slot wird an eine Adresse gebunden`,en:`${t.label.en}: A literal for the reference-typed slot "${r.id}" is not allowed \u2014 the slot is bound to an address`},severity:"error"});return n}s(XO,"findParamValueRefSlotErrors");function eP(e){let n=[];for(let t of e.nodes){let r=He(t);if(typeof r.inputs=="function")for(let i of r.inputs(t)){let o=t.inputs?.[i.id];if(o?.kind==="cockpit"&&i.deferrable!==!0){n.push({layer:"GRAPH",kind:"modelError",path:`nodes.${t.id}.inputs.${i.id}`,reason:{de:`[inputs/notDeferrable] ${t.label.de}: Parameter \u201E${i.label.de}\u201C l\xE4sst sich nicht im Cockpit erg\xE4nzen \u2014 nur Parameter eines Generators oder einer Vorlage.`,en:`[inputs/notDeferrable] ${t.label.en}: Parameter "${i.label.en}" cannot be completed in the cockpit \u2014 only parameters of a generator or a template can.`},severity:"error"});continue}(i.inspector==="literal-only"&&o?.kind==="binding"||i.inspector==="binding-only"&&o?.kind==="literal")&&n.push({layer:"GRAPH",kind:"modelError",path:`nodes.${t.id}.inputs.${i.id}`,reason:i.inspector==="literal-only"?{de:`[inputs/inspectorKind] ${t.label.de}: Parameter \u201E${i.label.de}\u201C ist ein fester Wert \u2014 eine Bindung an eine Adresse ist hier nicht m\xF6glich.`,en:`[inputs/inspectorKind] ${t.label.en}: Parameter "${i.label.en}" is a fixed value \u2014 it cannot be bound to an address.`}:{de:`[inputs/inspectorKind] ${t.label.de}: Parameter \u201E${i.label.de}\u201C wird an eine Adresse gebunden \u2014 ein fester Wert ist hier nicht m\xF6glich.`,en:`[inputs/inspectorKind] ${t.label.en}: Parameter "${i.label.en}" is bound to an address \u2014 a fixed value is not possible here.`},severity:"error"})}}return n}s(eP,"findInspectorKindErrors");function nP(e){let n=[];for(let t of e.nodes)for(let r of ZO(t))n.push({layer:"GRAPH",kind:"contractGap",path:`node.${t.id}.input.${r.id}`,reason:{de:`${t.label.de}: Pflicht-Slot "${r.label.de}" nicht gesetzt`,en:`${t.label.en}: Required slot "${r.label.en}" is not set`},severity:"error"});return n}s(nP,"findMissingRequiredInputs");function Lf(e){let n=e.processStore;return n===void 0?[]:(Array.isArray(n)||F("graph.processStore must be an array \u2014 the graph validator refuses anything else"),n)}s(Lf,"processStoreKeys");function rP(e){let n=[];for(let t of e.tasks??[]){let r=t.result;if(!(r===void 0||!Ss(r)))for(let i of gf(r))n.push({key:i.key,nodeId:e.id,taskKey:t.key,template:t,result:r,valueType:i.valueType,...i.field!==void 0?{fieldKey:i.field.key}:{}})}return n}s(rP,"storeWritersOn");function iP(e){let n=new Map;for(let t of e.nodes)for(let r of rP(t)){let i=n.get(r.key)??[];i.push(r),n.set(r.key,i)}return n}s(iP,"processStoreWriters");function SW(e,n,t){for(let r of e.nodes){let i=rP(r).find(o=>o.taskKey===n&&o.key===t);if(i!==void 0)return i}return null}s(SW,"writerAt");function tP(e,n,t){(n.scope!=="task"||n.path!==void 0)&&F(`[process] ${t}: ${se(n)} is no task value`);let r=SW(e,n.owner,n.key);return r===null&&F(`[address/ownerNotWriter] ${t}: task "${n.owner}" writes no "${n.key}" \u2014 publish refuses that`),{key:n.key,nodeId:r.nodeId,taskKey:r.taskKey,...r.fieldKey!==void 0?{fieldKey:r.fieldKey}:{}}}s(tP,"sourceOfAddress");function Gy(e,n){(n.scope!=="task"&&n.scope!=="derived"||n.path!==void 0)&&F(`[process] ${se(n)} is no store address`);let t=Lf(e).find(o=>o.key===n.key);t===void 0&&F(`[address/unknownKey] ${se(n)}: "${n.key}" is not declared in processStore`);let r={key:t.key,type:t.type,label:t.label,audience:t.audience};if(n.scope==="task")return ky(t)&&F(`[address/unknownKey] ${se(n)}: "${n.key}" is a derived price \u2014 read it as $derived`),{...r,sources:[tP(e,n,se(n))]};ky(t)||F(`[address/unknownKey] ${se(n)}: "${n.key}" is a written value \u2014 read it as $task`);let i=by(e,t.derive).map(o=>tP(e,o.address,se(n)));return{...r,sources:i,derive:t.derive}}s(Gy,"processLeafOf");var zy=new Set(["enum","pricedItem","number","boolean","reduction"]),Wy=new Set(["pricedItem","pricedGroup"]),Yy=new Set(["number","boolean","enum"]),Le={invalidKey:"[process/invalidKey]",unknownKey:"[process/unknownKey]",secondWriter:"[process/secondWriter]",noWriter:"[process/noWriter]",writerTypeMismatch:"[process/writerTypeMismatch]",pricedItemWritesNothing:"[process/pricedItemWritesNothing]",ruleSet:"[process/ruleSet]",ruleCondition:"[process/ruleCondition]",ruleSource:"[process/ruleSource]",ruleReadsAbsent:"[process/ruleReadsAbsent]",absentValue:"[process/absentValue]",derive:"[process/derive]",derivedHasWriter:"[process/derivedHasWriter]",ruleGrantUnknown:"[process/ruleGrantUnknown]",ruleGrantUnused:"[process/ruleGrantUnused]",derivePriceUnknown:"[process/derivePriceUnknown]",derivePriceNotInProgram:"[process/derivePriceNotInProgram]",derivePriceOfferWithoutProgram:"[process/derivePriceOfferWithoutProgram]",deriveStageUnknown:"[process/deriveStageUnknown]",deriveStageUncovered:"[process/deriveStageUncovered]",reductionPrices:"[process/reductionPrices]",internalInDocument:"[process/internalInDocument]",writerMustBlock:"[process/writerMustBlock]",absentWithoutDefault:"[process/absentWithoutDefault]",defaultItemMismatch:"[process/defaultItemMismatch]"};function Me(e,n,t,r){return{layer:"GRAPH",kind:"contractGap",path:e,reason:{de:`${n} ${t}`,en:`${n} ${r}`},severity:"error"}}s(Me,"err");function oP(e,n={}){let t=[],r=Lf(e),i=new Map(r.map(d=>[d.key,d])),o=new Set;for(let[d,c]of r.entries()){let u=`processStore[${d}]`;if(typeof c.key!="string"||!/^[a-z][a-zA-Z0-9_]*$/.test(c.key)){t.push(Me(u,Le.invalidKey,`Vorgangs-Schl\xFCssel ${JSON.stringify(c.key)} \u2014 erlaubt sind Buchstaben, Ziffern und _, beginnend mit einem Kleinbuchstaben.`,`Process key ${JSON.stringify(c.key)} \u2014 letters, digits and _ are allowed, starting with a lowercase letter.`));continue}o.has(c.key)&&t.push(Me(u,Le.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}" ist doppelt deklariert.`,`Process key "${c.key}" is declared twice.`)),o.add(c.key),(c.derive!==void 0?!Wy.has(c.type):!zy.has(c.type))&&t.push(c.derive!==void 0?Me(u,Le.derive,`Vorgangs-Schl\xFCssel "${c.key}" ist abgeleitet, hat aber den Typ "${c.type}" \u2014 abgeleitet wird nur ein Preis: ${[...Wy].join(", ")}.`,`Process key "${c.key}" is derived but has the type "${c.type}" \u2014 only a price can be derived: ${[...Wy].join(", ")}.`):Me(u,Le.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}" hat den Typ "${c.type}" \u2014 der Vorgang speichert nur Ergebnisse mit Wert: ${[...zy].join(", ")}${c.type==="pricedGroup"?" (ein Paket wird abgeleitet: derive)":""}.`,`Process key "${c.key}" has the type "${c.type}" \u2014 the process only stores results with a value: ${[...zy].join(", ")}${c.type==="pricedGroup"?" (a package is derived: derive)":""}.`)),(!c.label?.de?.trim()||!c.label?.en?.trim())&&t.push(Me(u,Le.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}" braucht ein Label in beiden Sprachen.`,`Process key "${c.key}" needs a label in both languages.`)),c.audience!=="internal"&&c.audience!=="printable"&&t.push(Me(u,Le.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}": audience muss 'internal' oder 'printable' sein.`,`Process key "${c.key}": audience must be 'internal' or 'printable'.`))}let a=iP(e);for(let d of e.nodes)for(let c of d.tasks??[]){let u=c.result;u?.kind==="pricedItem"&&u.writes===void 0&&t.push(Me(`node.${d.id}.tasks.${c.key}.result.writes`,Le.pricedItemWritesNothing,`Aufgabe "${c.key}" (Knoten "${d.id}") bepreist einen Artikel, schreibt das Ergebnis aber in keinen Vorgangs-Schl\xFCssel ('result.writes') \u2014 niemand k\xF6nnte den Preis lesen.`,`Task "${c.key}" (node "${d.id}") prices an article but writes the result to no process key ('result.writes') \u2014 nobody could read the price.`))}for(let[d,c]of a){let u=i.get(d);for(let p of c){let m=p.fieldKey===void 0?`node.${p.nodeId}.tasks.${p.taskKey}.result.writes`:`node.${p.nodeId}.tasks.${p.taskKey}.result.fields.${p.fieldKey}.writes`;if(u===void 0){t.push(Me(m,Le.unknownKey,`${p.fieldKey===void 0?"":`Feld "${p.fieldKey}" der `}Aufgabe "${p.taskKey}" schreibt "${d}", aber der Workflow deklariert keinen solchen Vorgangs-Schl\xFCssel (graph.processStore).`,`${p.fieldKey===void 0?"Task":`Field "${p.fieldKey}" of task`} "${p.taskKey}" writes "${d}", but the workflow declares no such process key (graph.processStore).`));continue}if(p.valueType!==u.type){let y=p.fieldKey===void 0?`Aufgabe "${p.taskKey}"`:`Feld "${p.fieldKey}" der Aufgabe "${p.taskKey}"`,k=p.fieldKey===void 0?`Task "${p.taskKey}"`:`Field "${p.fieldKey}" of task "${p.taskKey}"`;t.push(Me(m,Le.writerTypeMismatch,`${y} liefert ${p.valueType}, der Vorgangs-Schl\xFCssel "${d}" ist aber als ${u.type} deklariert.`,`${k} delivers ${p.valueType}, but the process key "${d}" is declared as ${u.type}.`))}}if(c.length>1){let p=c.map(m=>`${m.nodeId}/${m.taskKey}${m.fieldKey===void 0?"":`.${m.fieldKey}`}`).join(", ");t.push(Me(`processStore.${d}`,Le.secondWriter,`Vorgangs-Schl\xFCssel "${d}" wird ${c.length}-mal geschrieben (${p}) \u2014 genau ein Schreiber je Schl\xFCssel.`,`Process key "${d}" is written ${c.length} times (${p}) \u2014 exactly one writer per key.`))}}for(let d of r){if(d.derive!==void 0){if(a.has(d.key)){let c=a.get(d.key).map(u=>`${u.nodeId}/${u.taskKey}`).join(", ");t.push(Me(`processStore.${d.key}`,Le.derivedHasWriter,`Vorgangs-Schl\xFCssel "${d.key}" wird abgeleitet (derive) \u2014 keine Aufgabe darf ihn schreiben (${c}).`,`Process key "${d.key}" is derived (derive) \u2014 no task may write it (${c}).`))}continue}a.has(d.key)||t.push(Me(`processStore.${d.key}`,Le.noWriter,`Vorgangs-Schl\xFCssel "${d.key}" ist deklariert, aber keine Aufgabe schreibt ihn ('result.writes').`,`Process key "${d.key}" is declared, but no task writes it ('result.writes').`))}t.push(...AW(e,r,a,n));let l=new Map;for(let d of e.nodes){let c=He(d),u=typeof c.inputs=="function"?c.inputs(d):[];for(let p of u){let m=d.inputs?.[p.id];if(m?.kind!=="binding")continue;let y=EW(e,m.address);if(y===null)continue;let k=`node.${d.id}.input.${p.id}`,g=se(m.address);for(let E of y.sources){let A=l.get(E.key)??new Set;A.add(d.id),l.set(E.key,A)}if(y.audience==="internal"&&t.push(Me(k,Le.internalInDocument,`${d.label.de}: "${p.id}" liest den internen Vorgangs-Schl\xFCssel "${y.key}" \u2014 ein Dokument dieses Knotens geht an die Familie; nur 'printable'-Schl\xFCssel d\xFCrfen hinein.`,`${d.label.en}: "${p.id}" reads the internal process key "${y.key}" \u2014 a document of this node goes to the family; only 'printable' keys may go in.`)),y.derive!==void 0)continue;let v=TW(a,y.sources[0].key,y.sources[0].taskKey);if(v.template.when!==void 0&&p.required===!0&&p.defaultValue===void 0&&t.push(Me(k,Le.absentWithoutDefault,`${d.label.de}: "${p.id}" ist Pflicht und an ${g} gebunden, aber die schreibende Aufgabe entsteht nur unter einer Bedingung (when: ${Mf(v.template.when)}) \u2014 ohne Vorgabewert bliebe das Feld dann f\xFCr immer leer.`,`${d.label.en}: "${p.id}" is required and bound to ${g}, but the writing task only exists under a condition (when: ${Mf(v.template.when)}) \u2014 without a default value the field would stay empty forever.`)),v.result.kind==="pricedItem"&&p.defaultValue!==void 0){let E=p.defaultValue;(!Oi(E)||E.itemKey!==v.result.item||E.grantKeys.length>0)&&t.push(Me(k,Le.defaultItemMismatch,`${d.label.de}: der Vorgabewert von "${p.id}" muss der Artikel der schreibenden Aufgabe ohne Erm\xE4\xDFigung sein ({ itemKey: '${v.result.item??"?"}', grantKeys: [] }) \u2014 sonst rechnete die Familie ohne Antrag einen anderen Artikel als mit.`,`${d.label.en}: the default value of "${p.id}" must be the article of the writing task without a reduction ({ itemKey: '${v.result.item??"?"}', grantKeys: [] }) \u2014 otherwise the family would be charged a different article without an application than with one.`))}}}for(let[d,c]of l){let u=a.get(d)[0],p=u.template.blocks,m=p===void 0?void 0:p.node??u.nodeId,y=m!==void 0&&c.has(m)&&(()=>{let g=e.nodes.find(v=>v.id===m);return g!==void 0&&He(g).processHoldTemplate?.(g)===p.templateKey})(),k=`node.${u.nodeId}.tasks.${u.taskKey}.blocks`;if(!y){let g=[...c][0],v=e.nodes.find(A=>A.id===g),E=He(v).processHoldTemplate?.(v)??"?";t.push(Me(k,Le.writerMustBlock,`Die Aufgabe "${u.taskKey}" schreibt "${d}", h\xE4lt aber keinen der lesenden Knoten (${[...c].join(", ")}) zur\xFCck \u2014 sie muss den ersten blockieren, z. B. blocks: { ${g===u.nodeId?"":`node: '${g}', `}templateKey: '${E}' }, sonst arbeitet er, bevor der Wert existiert.`,`The task "${u.taskKey}" writes "${d}" but holds back none of the reading nodes (${[...c].join(", ")}) \u2014 it must block the first one, e.g. blocks: { ${g===u.nodeId?"":`node: '${g}', `}templateKey: '${E}' }, otherwise it works before the value exists.`));continue}for(let g of c)g===m||Pf(e,m,g)||t.push(Me(k,Le.writerMustBlock,`"${g}" liest "${d}", liegt aber nicht hinter dem zur\xFCckgehaltenen Knoten "${m}" \u2014 auf einem Weg an ihm vorbei l\xE4se er den Wert, bevor er feststeht.`,`"${g}" reads "${d}" but does not lie behind the held-back node "${m}" \u2014 on a path past it, it would read the value before it is settled.`))}return t}s(oP,"processBindingIssues");function AW(e,n,t,r){let i=[],o=new Map(n.map(u=>[u.key,u])),a=wf(e),l=new Set;for(let[u,p]of a.entries()){let m=`pricingRules[${u}]`;if((typeof p.key!="string"||!/^[a-z][a-zA-Z0-9_]*$/.test(p.key)||l.has(p.key))&&i.push(Me(m,Le.ruleSet,`Regelgruppe ${JSON.stringify(p.key)} \u2014 ein eindeutiger Schl\xFCssel aus Buchstaben, Ziffern und _, beginnend mit einem Kleinbuchstaben.`,`Rule group ${JSON.stringify(p.key)} \u2014 a unique key of letters, digits and _, starting with a lowercase letter.`)),l.add(p.key),(!p.label?.de?.trim()||!p.label?.en?.trim())&&i.push(Me(m,Le.ruleSet,`Regelgruppe "${p.key}" braucht ein Label in beiden Sprachen.`,`Rule group "${p.key}" needs a label in both languages.`)),!Array.isArray(p.rows)||p.rows.length===0){i.push(Me(m,Le.ruleSet,`Regelgruppe "${p.key}" hat keine Zeilen.`,`Rule group "${p.key}" has no rows.`));continue}for(let[y,k]of p.rows.entries()){let g=`${m}.rows[${y}]`;(!Array.isArray(k.grants)||k.grants.length===0||k.grants.some(E=>typeof E!="string"||E.length===0))&&i.push(Me(g,Le.ruleSet,`Regelgruppe "${p.key}", Zeile ${y+1}: nennt keine Rabattvorlage \u2014 eine Zeile ohne Rabatt ist die fehlende Zeile.`,`Rule group "${p.key}", row ${y+1}: names no discount template \u2014 a row without a discount is the missing row.`));let v=ml(k.when);if(v!==null){i.push(Me(g,Le.ruleCondition,`Regelgruppe "${p.key}", Zeile ${y+1}: Bedingung ${JSON.stringify(k.when)} \u2014 ${v}.`,`Rule group "${p.key}", row ${y+1}: condition ${JSON.stringify(k.when)} \u2014 ${v==="leere Bedingung"?"empty condition":v}.`));continue}for(let{identifier:E,address:A}of Ty(k.when)){if(A===null)continue;let I=$W(A,o,t);if(I==="ruleSource")i.push(Me(g,Le.ruleSource,`Regelgruppe "${p.key}", Zeile ${y+1}: liest ${E} \u2014 eine Bedingung liest nur Werte, die eine Aufgabe schreibt ($task.<aufgabe>.<schl\xFCssel>), vom Typ ${[...Yy].join(", ")}.`,`Rule group "${p.key}", row ${y+1}: reads ${E} \u2014 a condition only reads values that a task writes ($task.<task>.<key>), of type ${[...Yy].join(", ")}.`));else if(I==="ruleReadsAbsent"){let _=t.get(A.key).find(T=>T.taskKey===A.owner);i.push(Me(g,Le.ruleReadsAbsent,`Regelgruppe "${p.key}" liest ${E}, dessen Aufgabe entfallen kann (${_.template.when!==void 0?`when: ${Mf(_.template.when)}`:"sie endet mit ihrem Knoten"}) \u2014 der Schl\xFCssel muss sagen, wof\xFCr er ohne Aufgabe steht ('absentValue'), sonst entschiede die Regel still \xFCber einen fehlenden Wert.`,`Rule group "${p.key}" reads ${E}, whose task can lapse (${_.template.when!==void 0?`when: ${Mf(_.template.when)}`:"it ends with its node"}) \u2014 the key must say what it stands for without a task ('absentValue'), otherwise the rule would silently decide on a missing value.`))}}}}for(let u of n){if(u.absentValue===void 0)continue;let p=`processStore.${u.key}.absentValue`;if(!(u.type==="number"&&typeof u.absentValue=="number"||u.type==="boolean"&&typeof u.absentValue=="boolean"||u.type==="enum"&&typeof u.absentValue=="string"&&u.absentValue.length>0)){i.push(Me(p,Le.absentValue,`Vorgangs-Schl\xFCssel "${u.key}" (${u.type}): absentValue ${JSON.stringify(u.absentValue)} passt nicht zum Typ.`,`Process key "${u.key}" (${u.type}): absentValue ${JSON.stringify(u.absentValue)} does not fit the type.`));continue}let y=t.get(u.key)?.[0];y!==void 0&&!sP(y)&&i.push(Me(p,Le.absentValue,`Vorgangs-Schl\xFCssel "${u.key}": seine Aufgabe ist immer geschuldet und \xFCberlebt ihren Knoten \u2014 ein absentValue w\xFCrde nie gelesen.`,`Process key "${u.key}": its task is always owed and outlives its node \u2014 an absentValue would never be read.`))}let d=[];for(let u of n){let p=u.derive;if(p===void 0)continue;let m=`processStore.${u.key}.derive`,y=u.type==="pricedGroup"?"group":"item",k=[p.item,p.group,p.byStage].filter(T=>T!==void 0).length,g=vy(p),v=p.byStage??[];(k!==1||g.length===0||g.length!==Math.max(v.length,1)||g.some(T=>T.kind!==y))&&i.push(Me(m,Le.derive,`"${u.key}" (${u.type}) leitet ${y==="group"?"ein Paket ab: genau 'group' oder 'byStage' mit je einem 'group'":"einen Artikel ab: genau 'item' oder 'byStage' mit je einem 'item'"}.`,`"${u.key}" (${u.type}) derives ${y==="group"?"a package: exactly 'group' or 'byStage' with one 'group' each":"an article: exactly 'item' or 'byStage' with one 'item' each"}.`));let E=new Set;for(let[T,b]of v.entries()){if(!Array.isArray(b.stages)||b.stages.length===0){i.push(Me(`${m}.byStage[${T}]`,Le.derive,`"${u.key}": die Zeile ${T+1} nennt keine Stufe.`,`"${u.key}": row ${T+1} names no stage.`));continue}for(let R of b.stages)E.has(R)&&i.push(Me(`${m}.byStage[${T}]`,Le.derive,`"${u.key}": die Stufe "${R}" steht in mehr als einer Zeile \u2014 welcher Preis gilt, w\xE4re geraten.`,`"${u.key}": the stage "${R}" is in more than one row \u2014 which price applies would be a guess.`)),E.add(R)}let A=new Set;for(let T of p.rules??[]){let b=a.find(R=>R.key===T);if(b===void 0){i.push(Me(m,Le.derive,`"${u.key}" nennt die Regelgruppe "${T}", die der Workflow nicht deklariert (bekannt: ${a.map(R=>R.key).join(", ")||"keine"}).`,`"${u.key}" names the rule group "${T}", which the workflow does not declare (known: ${a.map(R=>R.key).join(", ")||"none"}).`));continue}for(let R of b.rows??[])for(let q of R.grants??[])A.add(q)}let I=p.reduction;we(I)&&(RW(I,o)||i.push(Me(m,Le.derive,`"${u.key}": Reduktion ${se(I)} ist kein von einer Aufgabe geschriebener Wert vom Typ reduction ($task.<aufgabe>.<schl\xFCssel>).`,`"${u.key}": reduction ${se(I)} is not a value of type reduction written by a task ($task.<task>.<key>).`)));for(let T of g)d.push({key:u.key,target:T,grants:A}),(T.kind==="item"?r.billingItemKeys?.has(T.key):r.groupArticleKeys?.has(T.key))===!1?i.push(Me(m,Le.derivePriceUnknown,`"${u.key}": ${T.kind==="item"?"der Artikel":"das Paket"} "${T.key}" ist nicht im Katalog des Mandanten.`,`"${u.key}": the ${T.kind==="item"?"article":"package"} "${T.key}" is not in the school's catalog.`)):r.offerProgram===null?i.push(Me(m,Le.derivePriceOfferWithoutProgram,`"${u.key}": das Angebot ist keinem Programm zugeordnet, also geh\xF6rt ${T.kind==="item"?"kein Artikel":"kein Paket"} zu ihm; dem Angebot ein Programm geben.`,`"${u.key}": the offer is not assigned to a program, so no ${T.kind==="item"?"article":"package"} belongs to it; give the offer a program.`)):r.offerProgram!==void 0&&((T.kind==="item"?r.offerProgram.billingItemKeys:r.offerProgram.groupKeys).has(T.key)||i.push(Me(m,Le.derivePriceNotInProgram,`"${u.key}": ${T.kind==="item"?"der Artikel":"das Paket"} "${T.key}" ist dem Programm \u201E${r.offerProgram.nameDe}\u201C des Angebots nicht zugeordnet${T.kind==="group"?" oder wird nicht angeboten":""} (unter Finanzen \u2192 Artikel zuordnen).`,`"${u.key}": the ${T.kind==="item"?"article":"package"} "${T.key}" is not assigned to the offer's program "${r.offerProgram.nameDe}"${T.kind==="group"?" or is not offered":""} (under Finance \u2192 assign articles).`)));let _=r.offerProgram?.stageKeys;if(p.byStage!==void 0&&_!==void 0){let T=[...E].filter(R=>!_.all.has(R));T.length>0&&i.push(Me(m,Le.deriveStageUnknown,`"${u.key}": ${T.map(R=>`"${R}"`).join(", ")} ist keine Stufe des Programms \u201E${r.offerProgram.nameDe}\u201C (Stufen: ${[..._.all].join(", ")||"keine"}).`,`"${u.key}": ${T.map(R=>`"${R}"`).join(", ")} ${T.length===1?"is not a stage":"are not stages"} of the program "${r.offerProgram.nameDe}" (stages: ${[..._.all].join(", ")||"none"}).`));let b=[..._.active].filter(R=>!E.has(R));b.length>0&&i.push(Me(m,Le.deriveStageUncovered,`"${u.key}": f\xFCr ${b.map(R=>`"${R}"`).join(", ")} nennt byStage keinen ${y==="group"?"Paket":"Artikel"} \u2014 diese Stufe h\xE4tte keinen Preis.`,`"${u.key}": for ${b.map(R=>`"${R}"`).join(", ")} byStage names no ${y==="group"?"package":"article"} \u2014 that stage would have no price.`))}}for(let u of t.values())for(let p of u){if(p.result.kind!=="reduction"||p.result.prices===void 0||p.result.writes===void 0)continue;let m=`node.${p.nodeId}.tasks.${p.taskKey}.result.prices`,k=o.get(p.result.prices)?.derive?.reduction;we(k)&&k.scope==="task"&&k.owner===p.taskKey&&k.key===p.result.writes||i.push(Me(m,Le.reductionPrices,`Aufgabe "${p.taskKey}" senkt "${p.result.prices}" \u2014 das muss ein abgeleiteter Preis sein, dessen derive.reduction $task.${p.taskKey}.${p.result.writes} ist.`,`Task "${p.taskKey}" reduces "${p.result.prices}" \u2014 that must be a derived price whose derive.reduction is $task.${p.taskKey}.${p.result.writes}.`))}let c=r.grantTemplates;if(c!==void 0){let u=new Set(a.flatMap(p=>(p.rows??[]).flatMap(m=>m.grants??[])));for(let p of u){let m=c.get(p);if(m===void 0){i.push(Me("pricingRules",Le.ruleGrantUnknown,`Eine Regelgruppe vergibt "${p}", aber keine Rabattvorlage des Mandanten tr\xE4gt diesen Schl\xFCssel.`,`A rule group grants "${p}", but no discount template of the school has this key.`));continue}d.some(({target:k,grants:g})=>{if(!g.has(p))return!1;if(k.kind==="item")return m.itemKeys.includes(k.key);let v=r.groupArticleKeys?.get(k.key);return m.itemKeys.some(E=>v?.has(E))})||i.push(Me("pricingRules",Le.ruleGrantUnused,`Die Rabattvorlage "${p}" (gebunden an Artikel "${m.itemKeys.join(", ")}") wird vergeben, aber kein abgeleiteter Preis, der ihre Regelgruppe liest, enth\xE4lt ihr Ziel \u2014 sie wirkte nirgends.`,`The discount template "${p}" (bound to article "${m.itemKeys.join(", ")}") is granted, but no derived price reading its rule group contains its target \u2014 it would have no effect anywhere.`))}}return i}s(AW,"derivedPriceIssues");function EW(e,n){if(!we(n)||n.scope!=="task"&&n.scope!=="derived"||n.path!==void 0)return null;let t=Lf(e).find(o=>o.key===n.key);if(t===void 0||n.scope==="derived"!=(t.derive!==void 0))return null;if(n.scope==="task")return Fr(e,n.owner,n.key)===null?null:Gy(e,n);let r=WI(e,t.derive),i=s(o=>o.scope==="task"&&o.path===void 0&&Fr(e,o.owner,o.key)!==null,"resolvable");return r!==null&&r.every(o=>i(o.address))?Gy(e,n):null}s(EW,"draftLeafOf");function TW(e,n,t){let r=e.get(n)?.find(i=>i.taskKey===t);return r===void 0&&F(`[process] the leaf of "${n}" names task "${t}", which does not write it`),r}s(TW,"writerOf");function Mf(e){return we(e)?se(e):JSON.stringify(e)}s(Mf,"shown");function $W(e,n,t){let r=e.scope==="task"&&e.path===void 0?n.get(e.key):void 0;if(e.scope==="task"&&e.path===void 0&&r===void 0)return null;if(e.scope!=="task"||r===void 0||r.derive!==void 0||!Yy.has(r.type))return"ruleSource";let i=t.get(r.key)?.find(o=>o.taskKey===e.owner);return i!==void 0&&sP(i)&&r.absentValue===void 0?"ruleReadsAbsent":null}s($W,"ruleSourceRefusal");function RW(e,n){let t=e.scope==="task"&&e.path===void 0?n.get(e.key):void 0;return t!==void 0&&t.type==="reduction"&&t.derive===void 0}s(RW,"isReductionValue");function sP(e){return e.template.when!==void 0||e.template.blocks?.node===void 0}s(sP,"writerMayBeNotOwed");function Hy(e){let n=He(e);return e.outcomes&&e.outcomes.length>0?[...e.outcomes]:n.outcomes&&n.outcomes.length>0?[...n.outcomes]:null}s(Hy,"nodeOutcomes");var IW=["documentChangeRequested","documentReturned"];function aP(e){return IW.includes(e)}s(aP,"isNonAdvancingExternalEvent");var js=["offer","contract"];function qf(e){return typeof e=="string"&&js.includes(e)}s(qf,"isArtifactSlotType");var lP="open",Bs="done";function Jy(e){let n={};for(let t of We)n[t]=e(t);return n}s(Jy,"localized");var dP=[{key:"tenantSlug",type:"string"}];var OW=/^(\d{4})-(\d{2})-(\d{2})$/;function PW(e){return e>=1900&&e<=2100}s(PW,"isSupportedYear");function NW(e,n,t){let r=new Date(Date.UTC(e,n-1,t));return r.getUTCFullYear()===e&&r.getUTCMonth()===n-1&&r.getUTCDate()===t}s(NW,"isRealDate");function Qy(e){if(typeof e!="string")return null;let n=OW.exec(e);if(n===null)return null;let[,t,r,i]=n;return t===void 0||r===void 0||i===void 0||!PW(Number(t))||!NW(Number(t),Number(r),Number(i))?null:{year:t,month:r,day:i}}s(Qy,"isoDateParts");var _W="Europe/Berlin";function uP(){return _W}s(uP,"tenantTimeZone");var cP=new Map;function CW(e){let n=cP.get(e);if(n)return n;let t;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{le("INVALID",{de:`Unbekannte Zeitzone "${e}".`,en:`Unknown time zone "${e}".`})}return cP.set(e,t),t}s(CW,"formatterFor");function DW(e,n){let t=new Map(CW(e).formatToParts(new Date(n)).map(a=>[a.type,a.value])),r=s(a=>{let l=t.get(a);return l===void 0&&F(`Zeitzone "${e}" liefert kein Feld ${a}.`),Number(l)},"read"),i=r("hour")%24;return Date.UTC(r("year"),r("month")-1,r("day"),i,r("minute"),r("second"))-Math.floor(n/1e3)*1e3}s(DW,"zoneOffsetAt");function Zy(e,n){let t=e+DW(n,e);return{wallClock:new Date(t).toISOString().slice(0,19),timeZone:n}}s(Zy,"instantToLocalDateTime");var Xy=3;function fP(e){return Zy(e,uP()).wallClock.slice(0,10)}s(fP,"localIsoDate");var Kf=["login","security","admission","tasks","deadlines","schoolMessages","staffTasks","staffAppointments","staffDeadlines","staffWaitlist","familyMessages","mentions"],pP=w.union(...Kf.map(e=>w.literal(e)));var ufe=w.union(w.literal("admission"),w.literal("tasks"),w.literal("staff"),w.literal("chat")),ew=["loginOnly","all"],ffe=w.union(w.literal("loginOnly"),w.literal("all"));function mP(e){return typeof e=="string"&&ew.includes(e)}s(mP,"isMailLevel");var El="subject";function hP(e){return e.category==="login"}s(hP,"isSignInLetter");var pn={key:"schoolName",label:"Name der Schule"},gP={de:"Zu Ihren Bewerbungen",en:"View your applications"},En={key:"portalLink",label:"Link zum Bewerberportal",required:!0,link:!0,actionLabel:gP},nw={key:En.key,label:En.label,link:!0,actionLabel:gP},yP={key:"authorName",label:"Name der schreibenden Person"},Vs={key:"applicationLink",label:"Link zur Bewerbung",required:!0,link:!0,actionLabel:{de:"Bewerbung \xF6ffnen",en:"Open application"}},Tl={key:"anmeldeLink",label:"Anmeldelink",required:!0,link:!0,actionLabel:{de:"Jetzt anmelden",en:"Sign in now"},previewValue:{de:"https://beispiel.plexus.schule/anmelden?token=BEISPIEL",en:"https://beispiel.plexus.schule/anmelden?token=BEISPIEL"}},LW={key:"passwortLink",label:"Link zum neuen Passwort",required:!0,link:!0,actionLabel:{de:"Neues Passwort festlegen",en:"Set a new password"},previewValue:{de:"https://beispiel.plexus.schule/login/reset?token=BEISPIEL",en:"https://beispiel.plexus.schule/login/reset?token=BEISPIEL"}},wP={key:"bestaetigungsLink",label:"Best\xE4tigungslink",required:!0,link:!0,actionLabel:{de:"E-Mail best\xE4tigen",en:"Confirm email address"},previewValue:{de:"https://beispiel.plexus.schule/bestaetigen?token=BEISPIEL",en:"https://beispiel.plexus.schule/bestaetigen?token=BEISPIEL"}},$l={key:"gueltigkeit",label:"G\xFCltigkeitsdauer des Links",previewValue:{de:"15 Minuten",en:"15 minutes"}},kP={key:"gueltigkeit",label:"G\xFCltigkeitsdauer des Links",previewValue:{de:"24 Stunden",en:"24 hours"}},MW={key:"gueltigkeit",label:"G\xFCltigkeitsdauer des Links",previewValue:{de:"60 Minuten",en:"60 minutes"}};function qe(e){return{key:El,label:"Betreff",default:e}}s(qe,"subjectSlot");var Mi=w.object({de:w.string(),en:w.string()}),Pn={tenantSlug:w.string(),applicationId:w.id("applications")},qW=w.object({tenantSlug:w.string()}),KW={id:"applicant.welcome",category:"admission",label:"Willkommen",occasion:{de:"Sobald f\xFCr eine Familie ein Zugang angelegt wurde",en:"As soon as an account has been created for a family"},audience:"external",frame:"letter",timeline:"correspondence",paramsValidator:qW,channels:["email"],portalVisible:!0,placeholders:[pn,En],slots:[qe({de:"Willkommen \u2014 Ihre Bewerbung bei uns",en:"Welcome \u2014 your application"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:`vielen Dank f\xFCr Ihre Registrierung bei {{schoolName}}. \xDCber den folgenden Link k\xF6nnen Sie jederzeit Ihre Bewerbungen einsehen und fortsetzen:
|
|
10943
10946
|
|
|
10944
10947
|
{{portalLink}}`,en:`Thank you for registering with {{schoolName}}. You can view and continue your applications at any time using the link below:
|
|
@@ -11167,7 +11170,7 @@ The link is valid for {{gueltigkeit}} and works once. Afterwards you are signed
|
|
|
11167
11170
|
|
|
11168
11171
|
{{einstellungenLink}}`,en:`Open Plexus and, in the user menu, \u201CSettings\u201D \u2192 \u201CSignature\u201D:
|
|
11169
11172
|
|
|
11170
|
-
{{einstellungenLink}}`}}]},ow=[KW,zW,HW,JW,QW,e1,m1,g1,$1,I1,P1,C1,L1,q1,B1,G1,Y1,J1,y1,w1,k1,Q1,Z1,X1,n1,t1,i1,a1,f1,A1,k2,v2,BW,UW,n2,r2,o2,a2,c2,f2,m2];function sw(e){let n=ow.find(t=>t.id===e);return n===void 0&&F(`notifications: unknown letter "${e}"`),n}s(sw,"letterDefFor");function aw(e){return ow.some(n=>n.id===e)}s(aw,"hasLetterDef");function lw(e,n){return n===void 0?!0:Af(e,n)}s(lw,"letterArgCompatible");function Ol(e){return e==="localizedText"?{de:"Text in jeder Sprache (localizedText)",en:"Text in every language (localizedText)"}:{de:`${xt(e)} (${e})`,en:`${xt(e)} (${e})`}}s(Ol,"letterArgTypeLabel");function SP(e){let n=new Map,t=s((r,i)=>{let o=n.get(r);o===void 0?n.set(r,[i]):o.push(i)},"add");for(let r of e.args)t(r.key,{source:`Ereignis "${e.id}"`,type:r.type,always:r.required===!0});for(let r of dP)t(r.key,{source:"Kontext des Versands",type:r.type,always:!0});return n}s(SP,"eventArgSources");function AP(e,n){let t=e.type===void 0?[...n]:n.filter(r=>lw(r.type,e.type));if(t.length>1)return{status:"ambiguous",matches:t};if(t.length===1){let r=t[0];return!e.required||r.always?{status:"resolved",source:r}:{status:"sometimes",source:r}}return e.required?{status:"missing",rejected:[...n]}:{status:"unused"}}s(AP,"resolveLetterParam");var dw=["booked","rescheduled","cancelled"],x2={booked:"admission.appointmentBooked",rescheduled:"admission.appointmentRescheduled",cancelled:"admission.appointmentCancelled"},TP=":";function $P(e,n){return`${e}${TP}${n}`}s($P,"appointmentEventId");function S2(e){let n=e.lastIndexOf(TP);if(n<=0)return null;let t=e.slice(n+1);return dw.includes(t)?{taskKey:e.slice(0,n),kind:t}:null}s(S2,"parseAppointmentEventId");var EP={booked:{de:"Termin vereinbart",en:"Appointment booked"},rescheduled:{de:"Termin verschoben",en:"Appointment moved"},cancelled:{de:"Termin abgesagt",en:"Appointment cancelled"}};function Gs(e){return Array.isArray(e.tasks)?e.tasks.filter(n=>typeof n?.key=="string"&&n.result?.kind==="appointment"):[]}s(Gs,"appointmentTasksOf");function A2(e){return dw.map(n=>({id:$P(e.key,n),label:{de:`${EP[n].de} \u2013 \u201E${e.title.de}\u201C`,en:`${EP[n].en} \u2013 \u201C${e.title.en}\u201D`},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"bookingId",type:"string",required:!0}]}))}s(A2,"appointmentTaskEvents");function RP(e,n){let t=n.notificationEvents?.(e)??[],r=Gs(e).flatMap(A2);return r.length===0?t:[...t,...r]}s(RP,"nodeNotificationEvents");function E2(e){return Object.fromEntries(dw.map(n=>[$P(e,n),{templateId:x2[n]}]))}s(E2,"defaultAppointmentBindings");function T2(e,n){if(e===void 0)return{notifications:e,dropped:[]};let t=[],r={};for(let[i,o]of Object.entries(e))S2(i)?.taskKey===n?t.push(i):r[i]=o;return t.length===0?{notifications:e,dropped:t}:{notifications:Object.keys(r).length===0?void 0:r,dropped:t}}s(T2,"withoutAppointmentBindings");function Gf(e,n,t){let r=new Set(Gs(n).map(d=>d.key)),i=new Set(Gs(t).map(d=>d.key)),o=e,a=[];for(let d of r){if(i.has(d))continue;let c=T2(o,d);o=c.notifications,a.push(...c.dropped)}let l=[];for(let d of i)if(!r.has(d))for(let[c,u]of Object.entries(E2(d)))o?.[c]===void 0&&(o={...o??{},[c]:u},l.push(c));return{notifications:o,bound:l,dropped:a}}s(Gf,"syncAppointmentBindings");function $2(e){return e.kind==="task"&&!("title"in e)}s($2,"isLegacyFreeTodoContext");function cw(e){let{context:n}=e;if($2(n)&&F(`[workItems/legacyFreeTodo] work_item ${e._id} is a free to-do in its former shape \u2014 run migrations:freeTodosToContext`),n.kind==="task")return{...e,context:n,kind:"task",createdVia:"human",partyId:n.partyId};let{anchor:t,task:r,kind:i,title:o,description:a,...l}=n,d=t.scope==="node"?{nodeId:t.nodeId,templateKey:t.templateKey,gatesNode:t.gatesNode,blocks:t.blocks}:t.scope==="application"?{scope:"application",templateKey:t.templateKey}:t.scope==="crossNode"?{scope:"application",nodeId:t.nodeId,templateKey:t.templateKey,blocks:t.blocks}:{};return{...e,context:n,...l,...d,...r??{},kind:i}}s(cw,"readWorkItem");async function Pl(e,n){let t;if(n.nodeId!==void 0){let r=n.nodeId;t=await e.db.query("work_items").withIndex("by_applicationId_and_nodeId",i=>i.eq("context.applicationId",n.applicationId).eq("context.anchor.nodeId",r)).collect()}else if(n.isOpen!==void 0){let r=n.isOpen;t=await e.db.query("work_items").withIndex("by_applicationId_and_isOpen",i=>i.eq("context.applicationId",n.applicationId).eq("isOpen",r)).collect()}else t=await e.db.query("work_items").withIndex("by_applicationId_and_nodeId",r=>r.eq("context.applicationId",n.applicationId)).collect();return t.filter(r=>n.isOpen===void 0||r.isOpen===n.isOpen).map(cw)}s(Pl,"listWorkItemsForApplication");var Kfe=w.union(w.literal("approved"),w.literal("rejected")),Nl=new Set(["task","approval"]);function R2(e,n){switch(e){case"task":return n?.gatesNode===!0&&F("expandComposedTask: gatesNode is approval-only \u2014 a 'task' template never gates its node (use blocks to hold a gating sibling back)"),{kind:"task",recipient:"internal",gatesNode:!1};case"approval":return{kind:"approval",recipient:"internal",isApproval:!0,gatesNode:n?.gatesNode??!0};default:F(`expandComposedTask: unknown composed-task kind ${JSON.stringify(e)} \u2014 authorable: ${[...Nl].join(", ")}`)}}s(R2,"expandComposedTask");for(let e of["task","approval"]){let n=R2(e);n.kind==="approval"!=(n.isApproval===!0)&&F(`composed-task kind "${e}": isApproval must be present iff kind === 'approval'`)}var IP=Ri,qi=`${IP}.`,I2=new Set(["text","number","date","boolean","option","edge"]);function zf(e,n){let t=e[n];return t===void 0&&F(`[env/unknownKey] no environment key '${n}'`),typeof t=="string"?null:Object.keys(t)}s(zf,"contextFields");function OP(e,n){return Object.hasOwn(e,n)}s(OP,"isContextKey");function PP(e){let n=[];for(let t of Object.keys(e)){let r=zf(e,t);if(r===null)n.push(t);else for(let i of r)n.push(`${t}.${i}`)}return n}s(PP,"leafPaths");function _l(e,n){let[t="",r,...i]=n.split(".");if(!OP(e,t)||i.length>0)return;let o=e[t];if(typeof o=="string")return r===void 0?o:void 0;if(!(r===void 0||!Object.hasOwn(o,r)))return o[r]}s(_l,"leafType");function NP(e){let n=new Set;for(let t of e){let r=zs(t);r!==null&&n.add(r.split(".")[0])}return[...n]}s(NP,"contextKeysOf");function zs(e){return e.startsWith(qi)?e.slice(qi.length):null}s(zs,"contextPathOf");function Cl(e){return e===IP||e.startsWith(qi)}s(Cl,"isContextIdentifier");function Wf(e,n){let t=zs(n)??"",[r=""]=t.split("."),i=Object.keys(e);if(!OP(e,r))return{code:"env/unknownKey",message:{de:`'${n}' nennt keinen Umgebungsschl\xFCssel \u2014 bekannt: ${i.join(", ")}.`,en:`'${n}' names no environment key \u2014 known: ${i.join(", ")}.`}};if(_l(e,t)!==void 0)return null;let o=zf(e,r);return{code:"env/unknownKey",message:o===null?{de:`'${n}': der Umgebungsschl\xFCssel '${r}' ist ein einzelner Wert \u2014 lies ihn als '${qi}${r}'.`,en:`'${n}': environment key '${r}' is a single value \u2014 read it as '${qi}${r}'.`}:{de:`'${n}': der Umgebungsschl\xFCssel '${r}' hat die Felder ${o.join(", ")}.`,en:`'${n}': environment key '${r}' has the fields ${o.join(", ")}.`}}}s(Wf,"identifierIssue");function Yf(e,n,t=Object.keys(e)){let r={};for(let i of t){let o=zf(e,i),a=Object.hasOwn(n,i)?n[i]:void 0;if(a===void 0&&F(`[env/missing] context key '${i}' was not supplied`),o===null){r[`${qi}${i}`]=a;continue}for(let l of o){let d=typeof a=="object"&&a!==null&&Object.hasOwn(a,l)?a[l]:void 0;d===void 0&&F(`[env/missing] context key '${i}' carries no '${l}'`),r[`${qi}${i}.${l}`]=d}}return r}s(Yf,"flatten");function _P(e,n,t){if(t===void 0)return!1;let r=zf(e,n);return r===null?!0:typeof t=="object"&&t!==null&&r.every(i=>t[i]!==void 0)}s(_P,"contextValueComplete");function O2(e,n){switch(n){case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";case"date":return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}/.test(e);default:return typeof e=="string"}}s(O2,"valueMatchesDataType");function CP(e,n,t=Object.keys(e.types)){let r=new Set(t);for(let i of PP(e.types)){if(!r.has(i.split(".")[0]))continue;let o=n[`${qi}${i}`];o===void 0&&F(`[env/missing] context path '${i}' was not supplied`);let a=e.fields[i];if(o===null){a.nullable||F(`[env/null] context path '${i}' is not nullable but carries null`);continue}let l=xt(_l(e.types,i));O2(o,l)||F(`[env/type] context path '${i}' expects ${l}, got ${JSON.stringify(o)}`),a.valueSet.kind==="fixed"&&!a.valueSet.values.includes(o)&&F(`[env/value] context path '${i}' carries '${String(o)}', outside ${a.valueSet.values.join(" | ")}`)}}s(CP,"assertContextValues");function P2(e){let n=[],t=PP(e.types);for(let r of t){let i=_l(e.types,r),o=xt(i);if(!_i(i)||o===void 0||!I2.has(o)){n.push(`'${r}' has type '${String(i)}', not a scalar value type`);continue}let a=Object.hasOwn(e.fields,r)?e.fields[r]:void 0;if(a===void 0){n.push(`'${r}' has no field spec (value set + nullability)`);continue}a.valueSet.kind==="fixed"&&(a.valueSet.values.length===0&&n.push(`'${r}' has an empty fixed value set`),o!=="text"&&o!=="option"&&n.push(`'${r}' is ${o}; a fixed value set needs a text or option leaf`))}for(let r of Object.keys(e.fields))t.includes(r)||n.push(`field spec '${r}' names no leaf of the schema`);return n}s(P2,"schemaIssues");function Ws(e){let n=P2(e);n.length>0&&F(`[env/schema] ${n.join("; ")}`)}s(Ws,"assertSchema");var Hf={length:{params:["text"],returns:"number"},years_between:{params:["date","date"],returns:"number"}};function Ki(e){return JSON.stringify(e)}s(Ki,"canonical");function Hs(e){return e.kind==="binary"&&e.op==="&&"?[...Hs(e.left),...Hs(e.right)]:[e]}s(Hs,"conjuncts");function LP(e,n){let t;try{t=In(e)}catch{return!1}let r=Ki(In(n));return Hs(t).some(i=>Ki(i)===r)}s(LP,"hasConjunct");function MP(e,n){try{return Ki(In(e))===Ki(In(n))}catch{return!1}}s(MP,"sameCondition");function qP(e){let n=[];for(let t of e)n.push(...xn(gr(t)));return NP(n)}s(qP,"contextKeysRead");function KP(e){try{return xn(In(e)).some(Cl)}catch{return!1}}s(KP,"readsContext");var N2=/^\d{4}-\d{2}-\d{2}$/,_2=new Set(["==","!=","<","<=",">",">=","in"]),C2=new Set(["<","<=",">",">="]);function Qf(e,n,t=[]){Ws(n);let r;try{r=In(e)}catch(a){let l=a.message;return[zn("condition/parse",`Bedingung '${e}' ist nicht lesbar: ${l}`,`condition '${e}' does not parse: ${l}`)]}let i=[];for(let a of xn(r)){if(!Cl(a)){i.push(zn("condition/foreignIdentifier",`'${a}' ist kein Umgebungswert \u2014 Bedingungen lesen nur '$env.*'`,`'${a}' is not a context identifier \u2014 conditions read only '$env.*'`));continue}let l=Wf(n.types,a);l!==null&&i.push(zn("condition/unknownIdentifier",l.message.de,l.message.en))}if(i.length>0)return i;let o=Lr(r,n,i);Dl(o)||i.push(zn("condition/notBoolean",`Bedingung '${e}' ist kein Ja/Nein-Ausdruck`,`condition '${e}' is not a yes/no expression`)),M2(r,n,i);for(let{identifier:a,op:l}of pw(r,n))i.push(zn("condition/unguardedNullable",`'${l}' \xFCber '${a}', das leer sein kann, braucht davor eine Absicherung '${a} != null &&'`,`'${l}' over '${a}', which may be null, needs a guard '${a} != null &&' before it`));return i.push(...D2(r,t)),i}s(Qf,"conditionIssues");function D2(e,n){let t=Hs(e).map(Ki);return n.flatMap(r=>{let i=In(r),o=F2(i);return o===null||!t.includes(Ki(o))?[]:[{severity:"info",code:"condition/guardForm",message:{de:`[condition/guardForm] eine gespiegelte Absicherung z\xE4hlt nicht \u2014 schreibe sie genau als '${r}'`,en:`[condition/guardForm] a mirrored guard does not count \u2014 write it exactly as '${r}'`}}]})}s(D2,"guardFormHints");function F2(e){if(e.kind!=="binary"||e.op!=="=="&&e.op!=="!=")return null;let n={...e,left:e.right,right:e.left};return Ki(n)===Ki(e)?null:n}s(F2,"mirror");function Dl(e){return e.t==="unknown"||e.t==="data"&&e.dt==="boolean"}s(Dl,"isBooleanish");function jP(e){let n=zs(e);return n===null&&F(`[condition/invariant] '${e}' reached a pass that only sees $env identifiers`),n}s(jP,"contextPath");function BP(e,n){let t=zs(n);return t!==null&&e.fields[t]?.nullable===!0}s(BP,"isNullableLeaf");function L2(e,n){let t=xt(_l(e.types,jP(n)));return t===void 0?{t:"unknown"}:{t:"data",dt:t}}s(L2,"identType");function Jf(e,n){return e.t==="unknown"||n.t==="unknown"||e.t==="null"||n.t==="null"?!0:e.t==="array"||n.t==="array"?!1:e.t==="str"&&n.t==="str"?!0:e.t==="str"?DP(e.value,n.dt):n.t==="str"?DP(n.value,e.dt):e.dt===n.dt}s(Jf,"fits");function DP(e,n){return n==="text"||n==="option"||n==="edge"?!0:n==="date"?N2.test(e):!1}s(DP,"strFits");function FP(e){return e.t==="unknown"?"unknown":e.t==="data"&&e.dt==="number"?"number":null}s(FP,"orderedCategory");function Lr(e,n,t){switch(e.kind){case"num":return{t:"data",dt:"number"};case"bool":return{t:"data",dt:"boolean"};case"str":return{t:"str",value:e.value};case"null":return{t:"null"};case"ident":return L2(n,e.path);case"arr":for(let r of e.items)Lr(r,n,t);return{t:"array"};case"unary":{let r=Lr(e.operand,n,t);return Dl(r)||t.push(zn("condition/notBoolean","'!' braucht einen Ja/Nein-Operanden","'!' needs a yes/no operand")),{t:"data",dt:"boolean"}}case"call":{let r=Object.hasOwn(Hf,e.name)?Hf[e.name]:void 0,i=e.args.map(l=>Lr(l,n,t));return r===void 0?(t.push(zn("condition/functionNotAllowed",`Funktion '${e.name}' ist nicht erlaubt \u2014 erlaubt: ${Object.keys(Hf).join(", ")}`,`function '${e.name}' is not allowed \u2014 allowed: ${Object.keys(Hf).join(", ")}`)),{t:"unknown"}):(i.length===r.params.length&&i.every((l,d)=>l.t!=="null"&&Jf(l,{t:"data",dt:r.params[d]}))||t.push(zn("condition/typeMismatch",`'${e.name}' nimmt (${r.params.join(", ")})`,`'${e.name}' takes (${r.params.join(", ")})`)),{t:"data",dt:r.returns})}case"if":{let r=Lr(e.cond,n,t);Dl(r)||t.push(zn("condition/notBoolean","'if' braucht eine Ja/Nein-Bedingung","'if' needs a yes/no condition"));let i=Lr(e.then,n,t),o=Lr(e.else,n,t);return Jf(i,o)||t.push(zn("condition/typeMismatch","die beiden Zweige von 'if' haben verschiedene Typen","the two arms of 'if' differ in type")),i.t==="null"?o:i}case"binary":{let r=Lr(e.left,n,t),i=Lr(e.right,n,t);if(e.op==="&&"||e.op==="||")(!Dl(r)||!Dl(i))&&t.push(zn("condition/notBoolean",`'${e.op}' braucht Ja/Nein-Operanden`,`'${e.op}' needs yes/no operands`));else if(e.op==="in")e.right.kind!=="arr"?t.push(zn("condition/inWithoutArray","'in' braucht rechts eine Liste, z. B. ['a', 'b']","'in' needs a list on its right, e.g. ['a', 'b']")):e.right.items.every(o=>Jf(r,Lr(o,n,[])))||t.push(zn("condition/typeMismatch","ein Listeneintrag von 'in' passt nicht zum Typ des linken Operanden","a list item of 'in' does not match the left operand's type"));else if(C2.has(e.op)){let o=FP(r),a=FP(i);(o===null||a===null||o!=="unknown"&&a!=="unknown"&&o!==a)&&t.push(zn("condition/orderedComparison",`'${e.op}' vergleicht nur Zahlen \u2014 f\xFCr Daten years_between(\u2026) verwenden`,`'${e.op}' compares only numbers \u2014 for dates use years_between(\u2026)`))}else Jf(r,i)||t.push(zn("condition/typeMismatch",`'${e.op}' vergleicht Werte verschiedener Typen`,`'${e.op}' compares values of different types`));return{t:"data",dt:"boolean"}}}}s(Lr,"typeOf");function uw(e){return e.kind==="str"||e.kind==="num"||e.kind==="bool"}s(uw,"isLiteral");function VP(e){let n=[],t=s(r=>{if(r.kind==="binary"&&_2.has(r.op)){if(r.left.kind==="ident"){let i=r.op==="in"&&r.right.kind==="arr"?r.right.items.filter(uw):uw(r.right)?[r.right]:[];i.length>0&&n.push({ident:r.left.path,literals:i})}r.right.kind==="ident"&&uw(r.left)&&n.push({ident:r.right.path,literals:[r.left]})}UP(r,t)},"visit");return t(e),n}s(VP,"comparedLiterals");function M2(e,n,t){for(let{ident:r,literals:i}of VP(e)){let o=q2(r,i,n);o!==null&&t.push(o)}}s(M2,"literalIssues");function fw(e,n){let t;try{t=In(e)}catch{return[]}let r=[];for(let{ident:i,literals:o}of VP(t)){let a=zs(i);if(!(a===null||n.fields[a]?.valueSet.kind!=="live"))for(let l of o)l.kind==="str"&&r.push({path:a,value:l.value})}return r}s(fw,"liveLiterals");function q2(e,n,t){let r=t.fields[jP(e)]?.valueSet;if(r?.kind==="unstable")return zn("condition/literalOnUnstable",`'${e}' ist nicht \xFCber Umgebungen stabil \u2014 vergleiche ihn mit keinem festen Wert; verzweige stattdessen \xFCber ein stabiles Merkmal`,`'${e}' is not stable across environments \u2014 compare it to no literal; branch on a stable attribute instead`);if(r?.kind!=="fixed")return null;let i=n.flatMap(a=>a.kind==="str"&&!r.values.includes(a.value)?[`'${a.value}'`]:[]);if(i.length===0)return null;let o=r.values.map(a=>`'${a}'`).join(", ");return zn("condition/literalOutsideSet",`'${e}' kennt nur ${o} \u2014 nicht ${i.join(", ")}`,`'${e}' takes only ${o} \u2014 not ${i.join(", ")}`)}s(q2,"valueSetIssue");function UP(e,n){switch(e.kind){case"binary":n(e.left),n(e.right);return;case"unary":n(e.operand);return;case"call":e.args.forEach(n);return;case"arr":e.items.forEach(n);return;case"if":n(e.cond),n(e.then),n(e.else);return;default:return}}s(UP,"forEachChild");function GP(e){return e.kind==="binary"&&(e.op==="=="||e.op==="!=")&&(e.left.kind==="ident"&&e.right.kind==="null"||e.left.kind==="null"&&e.right.kind==="ident")}s(GP,"isNullTest");function zP(e){return Hs(e).flatMap(n=>{let t=WP(n);return t===null?[]:[t]})}s(zP,"guardsOf");function Fl(e,n,t){switch(e.kind){case"ident":return BP(n,e.path)&&!t.has(e.path)?e.path:null;case"call":for(let r of e.args){let i=Fl(r,n,t);if(i!==null)return i}return null;case"if":return Fl(e.then,n,new Set([...t,...zP(e.cond)]))??Fl(e.else,n,t);default:return null}}s(Fl,"unguardedNullSource");function WP(e){return!GP(e)||e.kind!=="binary"||e.op!=="!="?null:e.left.kind==="ident"?e.left.path:e.right.kind==="ident"?e.right.path:null}s(WP,"guardedIdent");function Ys(e,n,t,r){if(e.kind==="binary"&&e.op==="&&"){let i=new Set(t);for(let o of Hs(e)){Ys(o,n,i,r);let a=WP(o);a!==null&&i.add(a)}return}if(e.kind==="if"){Ys(e.cond,n,t,r),Ys(e.then,n,new Set([...t,...zP(e.cond)]),r),Ys(e.else,n,t,r);return}if(e.kind==="binary"&&e.op==="!="&&e.left.kind!=="null"&&e.right.kind!=="null"){let i=Fl(e.left,n,t)??Fl(e.right,n,t);i!==null&&r(i,"!=")}if(e.kind==="unary"&&!GP(e.operand)){let i=xn(e.operand).filter(o=>BP(n,o)&&!t.has(o));i.length>0&&r(i[0],"!")}UP(e,i=>Ys(i,n,t,r))}s(Ys,"nullableReads");function pw(e,n){Ws(n);let t=[];return Ys(e,n,new Set,(r,i)=>{t.some(o=>o.identifier===r)||t.push({identifier:r,op:i})}),t}s(pw,"unguardedNullableReads");function zn(e,n,t){return{severity:"error",code:e,message:{de:`[${e}] ${n}`,en:`[${e}] ${t}`}}}s(zn,"error");function Ll(e){let n=Array.isArray(e.nodes)?e.nodes:[],t=new Set;for(let r of n)for(let i of Of(r))i.key!==null&&_s[i.leaf].involves&&t.add(i.key);return t}s(Ll,"declaredGroupKeys");var Js=rf;var K2="unit.key",j2="offer.key";function YP(e,n){return e===K2?n.unitKeys:e===j2?n.offerKeys:null}s(YP,"liveKeyUniverse");function Zf(e){return[wn,...[...Ll(e)].sort((n,t)=>n.localeCompare(t)).map(uf)]}s(Zf,"requiredSlots");var ji=`${sf("applicant.channel")} == 'staff'`;var hw=["strict","leastLoaded"];var mw=2;function HP(e){return e.some(n=>n.length===0)?{de:"nennt einen leeren Personenschl\xFCssel",en:"names an empty person key"}:new Set(e).size!==e.length?{de:"nennt eine Person zweimal",en:"names a person twice"}:e.length<mw?{de:`braucht mindestens ${mw} Personen`,en:`needs at least ${mw} people`}:null}s(HP,"rotationPoolProblem");function B2(e,n){let t=n===null?-1:e.indexOf(n);return[...e.slice(t+1),...e.slice(0,t+1)]}s(B2,"strictOrder");function JP(e){let n=B2(e.pool,e.previous).filter(i=>e.eligible.has(i));if(n.length===0)return null;if(e.mode==="strict")return n[0];let t=e.openCounts;t===void 0&&F("[assignment/rotation] leastLoaded needs the open counts");let r=s(i=>{let o=t.get(i);return o===void 0&&F(`[assignment/rotation] no open count for '${i}'`),o},"load");return n.reduce((i,o)=>r(o)<r(i)?o:i)}s(JP,"pickFromPool");function ZP(e){return e.map(n=>({slot:mI(n.slot),rules:[...n.rules]}))}s(ZP,"rulesOfStored");function XP(e){return e.map(n=>({slot:V2(n.slot),rules:[...n.rules]}))}s(XP,"storedOfRules");function V2(e){let n=pf(e);return n===null&&F(`[assignment/unknownSlot] '${e}' is no slot \u2014 'responsible' or 'team:<teamKey>'`),n}s(V2,"slotOf");function eN(e,n){let t=e?.assignmentRules;t===void 0&&F(`[assignment/noRules] ${n}: the workflow has no assignment rule`);let r=iN(t);return r.length>0&&F(`${r.join("; ")} (${n})`),ZP(t)}s(eN,"rulesOfGraph");function U2(e){return e===wn?{slot:e,rules:[{when:ji,assign:{kind:"creator"}},{when:null,assign:{kind:"unassigned"}}]}:{slot:e,rules:[{when:null,assign:{kind:"queue"}}]}}s(U2,"defaultSlotRules");function nN(e,n){let t=new Set(e.map(o=>o.slot)),r=n.filter(o=>!t.has(o)).map(U2);return[...r.filter(o=>o.slot===wn),...e,...r.filter(o=>o.slot!==wn)]}s(nN,"withRequiredSlots");function Nn(e,n){return n===void 0?`slot '${e}'`:`slot '${e}' row #${n+1}`}s(Nn,"where");function Nt(e,n){return n===void 0?`Liste '${e}'`:`Liste '${e}', Zeile #${n+1}`}s(Nt,"whereDe");function St(e,n,t={},r="error"){return{severity:r,code:e,message:{de:`[${e}] ${n.de}`,en:`[${e}] ${n.en}`},...t}}s(St,"issue");function QP(e){if(e===wn)return!0;let n=ff(e);return n!==null&&n.length>0}s(QP,"isKnownSlot");function G2(e,n){Ws(Js);let t=[],r=new Set;e.forEach((o,a)=>{let{slot:l}=o;QP(l)||t.push(St("assignment/unknownSlot",{de:`'${l}' ist keine Liste \u2014 'responsible' oder 'team:<teamKey>'`,en:`'${l}' is no slot \u2014 'responsible' or 'team:<teamKey>'`},{slot:l})),r.has(l)&&t.push(St("assignment/duplicateSlot",{de:`${Nt(l)} steht zweimal da`,en:`${Nn(l)} is listed twice`},{slot:l})),r.add(l),l===wn&&a!==0&&t.push(St("assignment/responsibleFirst",{de:`'${wn}' muss die erste Liste sein \u2014 Team-Zeilen \xFCbernehmen sie`,en:`'${wn}' must be the first slot \u2014 team rows copy it`},{slot:l})),t.push(...z2(o))});for(let o of n)r.has(o)||t.push(St("assignment/slotMissing",{de:`${Nt(o)} hat keine Regeln \u2014 der Workflow braucht sie`,en:`${Nn(o)} has no rule list \u2014 the workflow needs it`},{slot:o}));let i=new Set(n);for(let{slot:o}of e)o!==wn&&!i.has(o)&&QP(o)&&t.push(St("assignment/unusedSlot",{de:`${Nt(o)} wird hier nicht gebraucht \u2014 erlaubt, und nicht ausgewertet`,en:`${Nn(o)} is not needed here \u2014 allowed, and not evaluated`},{slot:o},"info"));return t}s(G2,"validateRules");function z2({slot:e,rules:n}){let t=[];return(n.length===0||n[n.length-1].when!==null)&&t.push(St("assignment/defaultRowMissing",{de:`${Nt(e)} muss mit einer Zeile ohne Bedingung enden (\u201Esonst\u201C)`,en:`${Nn(e)} must end with a row without condition ("otherwise")`},{slot:e})),n.forEach((r,i)=>{let o={slot:e,row:i},{when:a,assign:l}=r;if(a===null&&i<n.length-1&&t.push(St("assignment/ruleAfterDefault",{de:`${Nt(e,i)} hat keine Bedingung, aber es folgen Zeilen \u2014 sie treffen nie zu`,en:`${Nn(e,i)} has no condition, but rows follow it \u2014 they can never match`},o)),a!==null){let d=Qf(a,Js,[ji]);for(let c of d)t.push({...c,message:{de:`${c.message.de} (${Nt(e,i)})`,en:`${c.message.en} (${Nn(e,i)})`},...o});if(d.every(c=>c.severity!=="error")){KP(a)||t.push(St("assignment/shadowedRule",{de:`${Nt(e,i)} liest nichts aus dem Vorgang \u2014 sie gilt immer oder nie`,en:`${Nn(e,i)} reads nothing of the application \u2014 it holds for every application or for none`},o));let c=n.slice(0,i).findIndex(u=>u.when!==null&&MP(u.when,a));c!==-1&&t.push(St("assignment/shadowedRule",{de:`${Nt(e,i)} wiederholt die Bedingung von Zeile #${c+1} \u2014 sie trifft nie zu`,en:`${Nn(e,i)} repeats the condition of row #${c+1} \u2014 it can never match`},o))}}if(e===wn&&l.kind==="slot"&&t.push(St("assignment/slotForwardRef",{de:`${Nt(e,i)} \xFCbernimmt '${l.slot}' \u2014 das darf nur eine Team-Liste nach '${wn}'`,en:`${Nn(e,i)} copies '${l.slot}' \u2014 only a team slot after '${wn}' may`},o)),e===wn&&l.kind==="queue"&&t.push(St("assignment/queueOnProcessSlot",{de:`${Nt(e,i)} weist die Queue zu \u2014 die Prozesszust\xE4ndigkeit ist immer eine Person`,en:`${Nn(e,i)} assigns the queue \u2014 the responsible slot is always a person`},o)),l.kind==="unassigned"&&t.push(St("assignment/targetMissing",{de:`${Nt(e,i)} nennt noch niemanden \u2014 Person w\xE4hlen`,en:`${Nn(e,i)} names no one yet \u2014 choose a person`},o)),l.kind==="rotation"){let d=HP(l.configKeys);d!==null&&t.push(St("assignment/rotationPool",{de:`${Nt(e,i)}: die Reihum-Liste ${d.de}`,en:`${Nn(e,i)} rotates over a pool that ${d.en}`},o))}l.kind==="creator"&&(a===null||!LP(a,ji))&&t.push(St("assignment/unguardedTarget",{de:`${Nt(e,i)} weist die anlegende Person zu \u2014 die gibt es nur, wenn die Bedingung der Zeile '${ji}' ist (oder enth\xE4lt)`,en:`${Nn(e,i)} assigns the creator, which exists only when the row's condition is (or has the conjunct) '${ji}'`},o))}),t}s(z2,"rowIssues");function tN(e,n){for(let r of n)e.some(i=>i.slot===r)||F(`[assignment/slotMissing] ${Nn(r)} has no rule list`);let t=new Set(n);return e.filter(r=>t.has(r.slot))}s(tN,"selectSlots");function W2(e,n){return qP(tN(e,n).flatMap(t=>t.rules.flatMap(r=>r.when===null?[]:[r.when])))}s(W2,"contextKeysOfRules");function rN(e,n,t,r){Ws(Js);let i=tN(e,t),o=W2(e,t),a=Yf(Js.types,n,o);CP(Js,a,o);let l=[];for(let{slot:d,rules:c}of i){let u=c.findIndex((m,y)=>{if(m.when===null)return!0;for(let k of xn(gr(m.when)))Object.hasOwn(a,k)||F(`[condition/unknownIdentifier] ${Nn(d,y)} reads '${k}', which the context does not carry`);return VI(m.when,{values:a})});u===-1&&F(`[assignment/defaultRowMissing] ${Nn(d)}: no row matched and there is no default row`);let p=c[u].assign;l.push({slot:d,ruleIndex:u,assign:p,value:Y2(d,u,p,l,r)})}return l}s(rN,"evaluateRules");function Y2(e,n,t,r,i){switch(t.kind){case"person":return{kind:"value",value:i.person(t.configKey)};case"creator":return{kind:"value",value:i.creator()};case"rotation":return{kind:"value",value:i.rotation(t,{slot:e,row:n})};case"unassigned":return F(`[assignment/targetMissing] ${Nn(e,n)} names no one`);case"queue":return e===wn&&F(`[assignment/queueOnProcessSlot] ${Nn(e,n)} assigns the queue`),{kind:"queue"};case"slot":{let o=e===wn?void 0:r.find(a=>a.slot===t.slot);return o===void 0&&F(`[assignment/slotForwardRef] ${Nn(e,n)} copies '${t.slot}', which is not decided before it`),o.value}}}s(Y2,"resolveTarget");var gw={person:["kind","configKey"],creator:["kind"],slot:["kind","slot"],queue:["kind"],rotation:["kind","configKeys","mode"],unassigned:["kind"]};function H2(e){if(typeof e!="object"||e===null)return!1;let{kind:n,groupKey:t,...r}=e;return Object.keys(r).length>0?!1:n==="responsible"?t===void 0:n==="team"&&typeof t=="string"&&t.length>0}s(H2,"isStoredSlot");function iN(e){let n=[],t=s((r,i)=>n.push(`[assignment/shape] ${r}: ${i}`),"bad");return Array.isArray(e)?(e.forEach((r,i)=>{let o=`slots[${i}]`;if(typeof r!="object"||r===null)return t(o,"must be { slot, rules }");let{slot:a,rules:l,...d}=r;if(Object.keys(d).length>0&&t(o,`unknown field(s) ${Object.keys(d).join(", ")}`),H2(a)||t(o,"slot must be { kind: 'responsible' } or { kind: 'team', groupKey: '<team key>' }"),!Array.isArray(l))return t(o,"rules must be a list");l.forEach((c,u)=>{let p=`${o}.rules[${u}]`;if(typeof c!="object"||c===null)return t(p,"must be { when, assign }");let{when:m,assign:y,...k}=c;Object.keys(k).length>0&&t(p,`unknown field(s) ${Object.keys(k).join(", ")}`),m!==null&&typeof m!="string"&&t(p,"when must be a condition string or null (\u201Esonst\u201C)");let g=y?.kind;if(typeof y!="object"||y===null||typeof g!="string"||!Object.hasOwn(gw,g))return t(p,`assign must be one of ${Object.keys(gw).map(I=>`{kind:'${I}'}`).join(", ")}`);let v=gw[g],E=Object.keys(y);(E.some(I=>!v.includes(I))||v.some(I=>!E.includes(I)))&&t(p,`a '${g}' target has exactly the field(s) ${v.join(", ")}`);let A=y;if(g==="person"&&(typeof A.configKey!="string"||A.configKey.length===0)&&t(p,"a 'person' target needs a non-empty configKey"),g==="rotation"){let I=A.configKeys;(!Array.isArray(I)||I.some(_=>typeof _!="string"))&&t(p,"a 'rotation' target needs configKeys, a list of person keys"),hw.includes(A.mode)||t(p,`a 'rotation' target's mode is one of ${hw.map(_=>`'${_}'`).join(", ")}`)}g==="slot"&&A.slot!==wn&&t(p,`a 'slot' target copies '${wn}' and nothing else`)})}),n):(t("slots","must be a list of { slot, rules }"),n)}s(iN,"ruleShapeIssues");function oN(e){let n=e??{},t=[];if(n.teamOwnerBindings!==void 0&&t.push({de:"[assignment/legacyBindings] der Workflow tr\xE4gt noch teamOwnerBindings \u2014 die Zust\xE4ndigkeitsregel ersetzt sie; das Feld entfernen",en:"[assignment/legacyBindings] the workflow still carries teamOwnerBindings \u2014 the assignment rule replaces them; remove the field"}),n.assignmentRules===void 0)return t.push({de:"[assignment/noRules] der Workflow hat keine Zust\xE4ndigkeitsregel (graph.assignmentRules) \u2014 jeder Workflow muss sagen, wer zust\xE4ndig wird",en:"[assignment/noRules] the workflow has no assignment rule (graph.assignmentRules) \u2014 every workflow must say who becomes responsible"}),t;let r=iN(n.assignmentRules);if(r.length>0)return[...t,...r.map(o=>({de:o,en:o}))];let i=Zf({nodes:Array.isArray(n.nodes)?n.nodes:[]});for(let o of G2(ZP(n.assignmentRules),i))o.severity==="error"&&t.push(o.message);return t}s(oN,"workflowAssignmentIssues");function Xf(e,n){let o=new Map;for(let d of e)o.set(d,0);let a=new Map,l=[];for(let d of e){if((o.get(d)??0)!==0)continue;let c=[{id:d,edges:n(d),idx:0}];for(o.set(d,1),a.set(d,null);c.length>0;){let u=c[c.length-1];if(u.idx>=u.edges.length){o.set(u.id,2),c.pop();continue}let{target:p,edge:m}=u.edges[u.idx];u.idx++;let y=o.get(p)??0;if(y===1){let k=[p],g=u.id;for(;g&&g!==p;)k.push(g),g=a.get(g)??null;k.reverse(),l.push({edge:m,source:u.id,target:p,cycle:k})}else y===0&&(o.set(p,1),a.set(p,u.id),c.push({id:p,edges:n(p),idx:0}))}}return l}s(Xf,"detectBackEdges");var yw="team:",J2=/^[a-z0-9][a-z0-9-]*$/;function Q2(e){if(!e.startsWith(yw))return null;let n=e.slice(yw.length);return n.length>0?n:null}s(Q2,"teamKeyOfMember");function ep(e){return`${yw}${e}`}s(ep,"teamMember");function Qs(e){let n=e.channels;return n===void 0?[]:(Array.isArray(n)||F("graph.channels must be an array"),n)}s(Qs,"readAuthoredChannels");function sN(e){return[...Ll(e)].sort()}s(sN,"derivedChannelTeamKeys");function aN(e,n){let t=e.toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"channel";if(!n.has(t))return t;for(let r=2;;r++){let i=`${t}-${r}`;if(!n.has(i))return i}}s(aN,"mintChannelKey");function lN(e,n){let t=e.channels;if(t===void 0)return[];if(!Array.isArray(t))return[{path:"channels",reason:{de:"[channels/shape] graph.channels muss eine Liste sein.",en:"[channels/shape] graph.channels must be a list."}}];let r=[],i=Ll(e),o=new Set,a=new Map;return t.forEach((l,d)=>{let c=`channels[${d}]`,u=l;if(u===null||typeof u!="object"||typeof u.key!="string"||Rn(u.label)==="not-localized"||!Array.isArray(u.members)||!u.members.every(E=>typeof E=="string")){r.push({path:c,reason:{de:"[channels/shape] Ein Kanal braucht key, label ({ de, en }) und members (Liste von Texten).",en:"[channels/shape] A channel needs key, label ({ de, en }) and members (a list of texts)."}});return}let p={de:`Kanal "${u.key}"`,en:`Channel "${u.key}"`};J2.test(u.key)||r.push({path:`${c}.key`,reason:{de:`[channels/invalidKey] ${p.de}: Schl\xFCssel nur aus Kleinbuchstaben, Ziffern und Bindestrich.`,en:`[channels/invalidKey] ${p.en}: key only from lowercase letters, digits and hyphens.`}}),o.has(u.key)&&r.push({path:`${c}.key`,reason:{de:`[channels/duplicateKey] ${p.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[channels/duplicateKey] ${p.en}: key is used twice.`}}),o.add(u.key);let m=Rn(u.label);if(m!=="not-localized"&&m.length===2?r.push({path:`${c}.label`,reason:{de:`[channels/emptyLabel] ${p.de}: Bezeichnung fehlt.`,en:`[channels/emptyLabel] ${p.en}: name is missing.`}}):m!=="not-localized"&&m.length>0&&r.push({path:`${c}.label`,reason:{de:`[i18n/missingTranslation] ${p.de}: Bezeichnung fehlt in: ${m.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${p.en}: name is missing in: ${m.join(", ")} \u2014 every displayed text needs German and English.`}}),u.members.length===0){r.push({path:`${c}.members`,reason:{de:`[channels/emptyMembers] ${p.de}: mindestens ein Team.`,en:`[channels/emptyMembers] ${p.en}: at least one team.`}});return}let y=[];for(let E of u.members){let A=Q2(E);if(A===null){r.push({path:`${c}.members`,reason:{de:`[channels/invalidMember] ${p.de}: "${E}" ist kein "team:<schl\xFCssel>".`,en:`[channels/invalidMember] ${p.en}: "${E}" is not a "team:<key>".`}});continue}if(y.includes(A)){r.push({path:`${c}.members`,reason:{de:`[channels/duplicateMember] ${p.de}: Team "${A}" ist doppelt genannt.`,en:`[channels/duplicateMember] ${p.en}: team "${A}" is named twice.`}});continue}n!==void 0&&!n.has(A)&&r.push({path:`${c}.members`,reason:{de:`[channels/unknownTeam] ${p.de}: Team "${A}" gibt es in diesem Mandanten nicht (oder es ist die Bewerbergruppe).`,en:`[channels/unknownTeam] ${p.en}: team "${A}" does not exist at this school (or it is the applicant group).`}}),y.push(A)}if(y.length===0)return;let k=[...y].sort().join("+"),[g]=y;y.length===1&&g!==void 0&&i.has(g)&&r.push({path:`${c}.members`,reason:{de:`[channels/duplicatesDerived] ${p.de}: Team "${g}" ist am Prozess beteiligt und hat seinen Kanal schon automatisch.`,en:`[channels/duplicatesDerived] ${p.en}: team "${g}" takes part in the process and already has its channel automatically.`}});let v=a.get(k);v!==void 0?r.push({path:`${c}.members`,reason:{de:`[channels/duplicateMembership] ${p.de}: dieselben Teams wie Kanal "${v}" \u2014 zwei Tabs w\xE4ren derselbe Chat.`,en:`[channels/duplicateMembership] ${p.en}: the same teams as channel "${v}" \u2014 two tabs would be the same chat.`}}):a.set(k,u.key)}),r}s(lN,"channelIssues");var _pe=Object.freeze({});function Z2(e,n){return Object.freeze(Yf(Xr,e,n))}s(Z2,"formContextEntries");function dN(e){return e.env??[]}s(dN,"declaredContextKeys");function cN(e,n){return dN(e).every(t=>uN(t,n?.[t]))}s(cN,"scenarioContextComplete");function uN(e,n){return _P(Xr,e,n)}s(uN,"contextValueComplete");function fN(e,n){return Z2(n??{},dN(e))}s(fN,"scenarioContextEntries");function kw(e){return Cl(e)}s(kw,"isContextIdentifier");function X2(e,n,t){let r=Wf(Xr,e);if(r!==null)return{severity:"error",path:t,code:"env/unknownKey",message:r.message};let[,i=""]=e.split(".");return n.has(i)?null:{severity:"error",path:t,code:"env/undeclared",message:{de:`'${e}' liest den Umgebungsschl\xFCssel '${i}', den das Formular nicht in \`env\` deklariert.`,en:`'${e}' reads the environment key '${i}', which the form does not declare in \`env\`.`}}}s(X2,"contextIdentifierIssue");var ww=sf("stage.key");function eY(e){let n=[],t=s(i=>i.kind==="ident"&&i.path===ww,"isStageKey"),r=s(i=>{switch(i.kind){case"binary":if((i.op==="=="||i.op==="!=")&&(t(i.left)&&i.right.kind==="str"&&n.push(i.right.value),t(i.right)&&i.left.kind==="str"&&n.push(i.left.value)),i.op==="in"&&t(i.left)&&i.right.kind==="arr")for(let o of i.right.items)o.kind==="str"&&n.push(o.value);r(i.left),r(i.right);return;case"unary":r(i.operand);return;case"if":r(i.cond),r(i.then),r(i.else);return;case"call":i.args.forEach(r);return;case"arr":i.items.forEach(r);return;default:return}},"walk");return r(e),n}s(eY,"stageKeyLiterals");function np(e,n,t){return n===void 0?[]:eY(e).filter(r=>!n.has(r)).map(r=>mN(r,n,t))}s(np,"stageKeyAstIssues");function pN(e,n){if(n===void 0)return[];let t=[];for(let r of e.testScenarios??[]){let i=r.env?.stage;typeof i?.key=="string"&&!n.has(i.key)&&t.push(mN(i.key,n,`scenario:${r.id}/env`))}return t}s(pN,"scenarioStageKeyIssues");function mN(e,n,t){let r=[...n].sort();return{severity:"error",path:t,code:"env/unknownStageKey",message:{de:`'${e}' ist kein Stufenschl\xFCssel des Programms dieses Angebots \u2014 `+(r.length>0?`bekannt: ${r.join(", ")}.`:"das Angebot hat kein Programm mit Stufen.")+` \`${ww}\` ist der Bundle-Schl\xFCssel (\`program.stages[].key\`), nie das gespeicherte \`<program>-stufe-<key>\`.`,en:`'${e}' is not a stage key of the offer's program \u2014 `+(r.length>0?`known: ${r.join(", ")}.`:"the offer has no program with stages.")+` \`${ww}\` is the bundle key (\`program.stages[].key\`), never the stored \`<program>-stufe-<key>\`.`}}}s(mN,"unknownStageKeyIssue");function hN(e,n,t){let r=[];for(let i of xn(e)){if(!kw(i))continue;let o=X2(i,n,t);o!==null&&r.push(o)}if(r.length>0)return r;for(let{identifier:i,op:o}of pw(e,rf))r.push({severity:"error",path:t,code:"env/unguardedNullable",message:{de:`'${o}' \xFCber '${i}', das bei manchen Bewerbungen leer ist, braucht davor eine Absicherung '${i} != null &&' \u2014 lege fest, was ein leerer Wert bedeutet.`,en:`'${o}' over '${i}', which is empty for some applications, needs a guard '${i} != null &&' before it \u2014 say what an empty value means.`}});return r}s(hN,"contextAstIssues");function gN(e,n){let t=[...nY(e)],r=new Set(e.env??[]);for(let i of e.env??[]){if(!ws(i)){t.push({severity:"error",path:"env",code:"env/unknownKey",message:{de:`Der deklarierte Umgebungsschl\xFCssel '${i}' geh\xF6rt nicht zum Vokabular (${ys.join(", ")}).`,en:`Declared environment key '${i}' is not in the vocabulary (${ys.join(", ")}).`}});continue}n!==void 0&&!n.has(i)&&t.push({severity:"error",path:"env",code:"env/unsupplied",message:{de:`Das Formular deklariert den Umgebungsschl\xFCssel '${i}', aber sein Host liefert ihn nicht.`,en:`The form declares environment key '${i}', but its host does not supply it.`}})}for(let i of e.testScenarios??[]){let o=[...r].filter(a=>ws(a)&&!uN(a,i.env?.[a]));o.length>0&&t.push({severity:"error",path:`scenario:${i.id}/env`,code:"env/unsampled",message:{de:`Szenario '${i.id}' belegt den deklarierten Umgebungsschl\xFCssel ${o.map(a=>`'${a}'`).join(", ")} nicht vollst\xE4ndig \u2014 eine echte Bewerbung tr\xE4gt immer jedes seiner Felder (ein leeres als null).`,en:`Scenario '${i.id}' does not sample the declared environment key(s) ${o.map(a=>`'${a}'`).join(", ")} completely \u2014 a real application always carries every field of them (an empty one as null).`}});for(let a of Object.keys(i.env??{}))ws(a)?r.has(a)||t.push({severity:"error",path:`scenario:${i.id}/env`,code:"env/undeclared",message:{de:`Szenario '${i.id}' belegt den Umgebungsschl\xFCssel '${a}', den das Formular nicht deklariert.`,en:`Scenario '${i.id}' samples environment key '${a}', which the form does not declare.`}}):t.push({severity:"error",path:`scenario:${i.id}/env`,code:"env/unknownKey",message:{de:`Szenario '${i.id}' belegt den unbekannten Umgebungsschl\xFCssel '${a}'.`,en:`Scenario '${i.id}' samples unknown environment key '${a}'.`}})}return t}s(gN,"formContextIssues");function nY(e){let n=[];Object.hasOwn(e,"context")&&n.push({severity:"error",path:"context",code:"env/retiredField",message:{de:"`context` ist abgeschafft \u2014 ein Formular deklariert die gelesene Umgebung als `env`.",en:"`context` is retired \u2014 a form declares the environment it reads as `env`."}});let t=e.testScenarios;for(let r of Array.isArray(t)?t:[])r!==null&&typeof r=="object"&&Object.hasOwn(r,"context")&&n.push({severity:"error",path:`scenario:${String(r.id)}/context`,code:"env/retiredField",message:{de:"`context` ist abgeschafft \u2014 ein Szenario belegt die Umgebung als `env`.",en:"`context` is retired \u2014 a scenario samples the environment as `env`."}});return n}s(nY,"retiredContextFields");function tp(e,n,t){let r=Qf(e,n).filter(o=>o.severity==="error").map(o=>o.message);if(r.length>0)return r;let i=[];if(t?.liveEnvKeys!==void 0)for(let o of fw(e,n)){let a=YP(o.path,t.liveEnvKeys);a===null&&F(`[condition] no live-key universe for '${o.path}' \u2014 extend liveKeyUniverse`),a.has(o.value)||i.push({de:`$env.${o.path} == '${o.value}' nennt keinen Schl\xFCssel dieses Mandanten.`,en:`$env.${o.path} == '${o.value}' names no key of this school.`})}for(let o of np(In(e),t?.stageKeys,""))i.push({de:`[${o.code}] ${o.message.de}`,en:`[${o.code}] ${o.message.en}`});return i}s(tp,"envConditionFindings");function rp(e){return e.kind==="entered"&&!e.repeated&&e.reviewRequired}s(rp,"isReviewField");function Zs(e){let n=[],t=[];function r(g,v){try{return In(g)}catch(E){n.push({path:v,src:g,reason:E instanceof Error?E.message:String(E)});return}}s(r,"tryParse");function i(g,v){return{...g,visibleIf:g.visibleIf?r(g.visibleIf,`${v}.visibleIf`):void 0,requiredIf:g.requiredIf?r(g.requiredIf,`${v}.requiredIf`):void 0,disabledIf:g.disabledIf?r(g.disabledIf,`${v}.disabledIf`):void 0,defaultValue:g.defaultValue?r(g.defaultValue,`${v}.defaultValue`):void 0}}s(i,"compileField");function o(g,v){return{...g,visibleIf:g.visibleIf?r(g.visibleIf,`${v}.visibleIf`):void 0,fields:g.fields.map((E,A)=>i(E,`${v}.fields[${A}]`))}}s(o,"compileGroup");function a(g,v){return{...g,itemTemplate:g.itemTemplate.map((E,A)=>i(E,`${v}.itemTemplate[${A}]`)),effects:g.effects?.map((E,A)=>d(E,`${v}.effects[${A}]`)),itemVisibleIf:g.itemVisibleIf?r(g.itemVisibleIf,`${v}.itemVisibleIf`):void 0}}s(a,"compileRepeated");function l(g,v){let E=[];return g.fields.forEach((A,I)=>{if(A.externalFlag){t.push({key:A.key,label:A.label,defaultValue:A.defaultValue?r(A.defaultValue,`${v}.fields[${I}].defaultValue`):void 0});return}E.push(i(A,`${v}.fields[${I}]`))}),{...g,visibleIf:g.visibleIf?r(g.visibleIf,`${v}.visibleIf`):void 0,fields:E,groups:g.groups?.map((A,I)=>o(A,`${v}.groups[${I}]`)),computed:g.computed?.map((A,I)=>{let _=r(A.expression,`${v}.computed[${I}].expression`);return{key:A.key,expression:_??{kind:"null"}}}),subsections:g.subsections?.map((A,I)=>l(A,`${v}.subsections[${I}]`)),repeated:g.repeated?.map((A,I)=>a(A,`${v}.repeated[${I}]`)),validators:g.validators}}s(l,"compileSection");function d(g,v){return{...g,when:g.when?r(g.when,`${v}.when`):void 0}}s(d,"compileEffect");function c(g,v){let E=r(g.when,`${v}.when`);return E?{...g,when:E}:null}s(c,"compileOutcome");let u=e.sections.map((g,v)=>l(g,`sections[${v}]`)),p=(e.effects??[]).map((g,v)=>d(g,`effects[${v}]`)),m=[],y=e.outcomes??[];for(let g=0;g<y.length;g++){let v=y[g],E=c(v,`outcomes[${g}]`);E&&m.push(E)}return{compiled:{...e,sections:u,effects:p,outcomes:m,flags:t},errors:n}}s(Zs,"compileForm");var tY=new Set(["decision","review","governedDocument"]);function wN(e){return tY.has(e.type)&&!(e.type==="governedDocument"&&e.production==="none")}s(wN,"isReadinessGatedNode");function rY(e){let n=new Map,t=oY(e),r=s((i,o)=>{let a=bw(o),l=[...i.fields,...(i.groups??[]).flatMap(d=>d.fields)];for(let d of l)d.externalFlag!==!0&&n.set(d.key,{kind:"entered",key:d.key,label:d.label,qualifier:iY(d.bucket,t,a),section:a,type:d.type,enumSource:yN(d),repeated:!1,reviewRequired:d.reviewRequired===!0});for(let d of i.repeated??[])for(let c of d.itemTemplate){let u=`${d.key}.${c.key}`;n.set(u,{kind:"entered",key:u,label:c.label,qualifier:bw(d),section:a,type:c.type,enumSource:yN(c),repeated:!0,reviewRequired:!1})}for(let d of i.computed??[]){let c=xn(In(d.expression));n.set(d.key,{kind:"computed",key:d.key,label:d.label??{de:d.key,en:d.key},qualifier:a,deps:c})}for(let d of i.subsections??[])r(d,o)},"visit");for(let i of e.sections)r(i,i);return n}s(rY,"formFieldCatalog");function yN(e){return e.type==="enum"?e:null}s(yN,"enumSourceOf");function iY(e,n,t){return e===void 0?t:n.get(e)??t}s(iY,"fieldQualifier");function oY(e){let n=new Map,t=s((r,i)=>{i===void 0||n.has(r)||n.set(r,bw(i))},"add");for(let r of bN(e))r.kind==="person"?t(r.bucket,r.display):r.kind==="organization"&&t(r.id.replace(/^o\./,""),r.display);return n}s(oY,"bucketWordings");function kN(e){return e.flatMap(n=>[n,...kN(n.subsections??[])])}s(kN,"allSections");function bN(e){return[...e.effects,...kN(e.sections).flatMap(n=>(n.repeated??[]).flatMap(t=>t.effects??[]))]}s(bN,"allEffects");function bw(e){return{label:e.label}}s(bw,"wordingOf");function vN(e){return vl(e).flatMap(({slot:n,address:t})=>{let r=XI(t);return r===null||bl.includes(r.path)?[]:[{slotId:n,owner:r.owner,fieldKey:r.path}]})}s(vN,"admissionBindingLeaves");function sY(e,n){let t=e.get(n);if(t===void 0)return null;let r=[],i=new Set,o=s(a=>{if(!i.has(a.key)&&(i.add(a.key),r.push({fieldKey:a.key,kind:a.kind}),a.kind==="computed"))for(let l of a.deps){let d=e.get(l);d!==void 0&&o(d)}},"walk");return o(t),r}s(sY,"expandKey");function aY(e){let n=new Set;for(let t of bN(e))if(!(t.kind!=="person"||t.contractParty===void 0)&&t.when!==void 0)for(let r of xn(In(t.when)))n.add(r);return[...n]}s(aY,"contractPartyConditionKeys");function lY(e){return Zs(e).compiled.flags.map(n=>({key:n.key,name:n.label}))}s(lY,"formExternalFlags");function xN(e){return{readinessFormFieldsByFormNode:new Map([...e].map(([n,t])=>[n,rY(t)])),readinessPartyConditionKeysByFormNode:new Map([...e].map(([n,t])=>[n,new Set(aY(t))])),formFlagKeysByFormNode:new Map([...e].map(([n,t])=>[n,new Set(lY(t).map(r=>r.key))])),formViewKeysByFormNode:new Map([...e].map(([n,t])=>[n,new Set((t.views??[]).map(r=>r.key))]))}}s(xN,"readinessUniverse");function vw(e,n){let t=new Set;for(let r of n)for(let i of sY(e,r)??[])i.kind==="entered"&&t.add(i.fieldKey);return t}s(vw,"enteredFieldsBehind");var dY=new Set(["label","sublabel","title","description","body","chipLabel","nextAction","confirmLabel","placeholder","helpText","subject","heading","hint","notice","reason"]);function cY(e){return dY.has(e)?!0:SN(e)?!1:/(Label|Title|Body|Description|Text|Hint|Heading|Placeholder)$/.test(e)}s(cY,"isTextKey");function SN(e){return/^localized[A-Z]/.test(e)}s(SN,"isLegacyTwinKey");var uY=new Set(["titles","responseLabels","outputLabels","enumOptionLabels"]),fY=new Set(["inputs","resolver","library"]);function op(e,n){let t=[];return xw(e,n,t),t}s(op,"findUnlocalizedTexts");function xw(e,n,t){if(Array.isArray(e)){e.forEach((i,o)=>xw(i,`${n}[${mY(i,o)}]`,t));return}if(e===null||typeof e!="object")return;let r=e;for(let[i,o]of Object.entries(r)){let a=`${n}.${i}`;if(!fY.has(i)){if(SN(i)){t.push({path:a,missing:"legacy-twin"});continue}if(cY(i)){pY(o,a,t);continue}if(uY.has(i)&&o!==null&&typeof o=="object"){for(let[l,d]of Object.entries(o))d!==void 0&&AN(d,`${a}.${l}`,t);continue}xw(o,a,t)}}}s(xw,"walk");function pY(e,n,t){e!=null&&AN(e,n,t)}s(pY,"checkText");function AN(e,n,t){let r=Rn(e);(r==="not-localized"||r.length>0)&&t.push({path:n,missing:r})}s(AN,"report");function mY(e,n){if(e!==null&&typeof e=="object"){let t=e;if(typeof t.id=="string")return t.id;if(typeof t.key=="string")return t.key}return String(n)}s(mY,"keyOf");function ip(e,n){return e==="not-localized"?n==="de"?"ist kein zweisprachiger Text ({ de, en })":"is not a bilingual text ({ de, en })":e==="legacy-twin"?n==="de"?'ist ein Zwilling der alten Form \u2014 der Text geh\xF6rt in das Feld ohne \u201Elocalized"':'is a twin of the old shape \u2014 the text belongs in the field without "localized"':n==="de"?`fehlt in: ${e.join(", ")}`:`is missing in: ${e.join(", ")}`}s(ip,"describe");function Sw({path:e,missing:n}){return n==="legacy-twin"?{de:`[i18n/legacyTwin] ${e} ${ip(n,"de")}.`,en:`[i18n/legacyTwin] ${e} ${ip(n,"en")}.`}:{de:`[i18n/missingTranslation] ${e} ${ip(n,"de")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch; die Sprache folgt dem Konto des Lesenden.`,en:`[i18n/missingTranslation] ${e} ${ip(n,"en")} \u2014 every displayed text needs German and English; the language follows the reader's account.`}}s(Sw,"unlocalizedTextReason");var hY={engagePush:["engage"]};function gY(e){let n=hY[e.type];return n===void 0?e:Object.fromEntries(Object.entries(e).filter(([t])=>!n.includes(t)))}s(gY,"withoutMachineData");function EN(e,n){return[...op(e.nodes.map(gY),"nodes"),...n===void 0?[]:op(n,`layout.${n.id}`)].map(r=>({layer:"GRAPH",kind:"i18n",path:r.path,reason:Sw(r),severity:"error"}))}s(EN,"checkLocalizedTexts");var Ao=5,Eo=480;function Mr(e){return typeof e=="string"&&e.trim().length>0}s(Mr,"isNonEmptyString");function $N(e,n,t){return Object.keys(e).filter(r=>!n.includes(r)).map(r=>({field:`result.${r}`,code:Ze.unknownField,message:{de:`Unbekanntes Feld '${r}' im ${t.de}; erlaubt sind: ${n.join(", ")}.`,en:`Unknown field '${r}' in the ${t.en}; allowed: ${n.join(", ")}.`}}))}s($N,"unknownFieldIssues");function yY(e){let n=[],t=e.title;(t===void 0||typeof t!="object"||t===null||!Mr(t.de)||!Mr(t.en))&&n.push({field:"result.title",code:Ze.appointmentMissingTitle,message:{de:"Ein Termin-Ergebnis braucht einen neutralen Titel in beiden Sprachen ({ de, en }) \u2014 er steht in der Mail und in der Kalenderdatei der Familie, deshalb nie ein Familienname.",en:"An appointment result needs a neutral title in both languages ({ de, en }) \u2014 it appears in the email and in the family's calendar file, so never a family name."}});let r=e.durationMinutes;return(typeof r!="number"||!Number.isInteger(r)||r<Ao||r>Eo)&&n.push({field:"result.durationMinutes",code:Ze.appointmentInvalidDuration,message:{de:`'durationMinutes' muss eine ganze Zahl von ${Ao} bis ${Eo} sein, erhalten ${JSON.stringify(r)}.`,en:`'durationMinutes' must be a whole number from ${Ao} to ${Eo}, got ${JSON.stringify(r)}.`}}),n.push(...$N(e,["kind","title","durationMinutes"],{de:"Termin-Ergebnis",en:"appointment result"})),n}s(yY,"appointmentIssues");function TN(e){if(typeof e!="object"||e===null)return!1;let n=e;return Mr(n.de)&&Mr(n.en)}s(TN,"isBilingual");var Aw=["key","type","label","writes","options","min","suggest","evidence","evidenceFrom"];function wY(e){let n=s((i,o)=>({field:i,code:Ze.recordFields,message:o}),"issue");if(!Array.isArray(e)||e.length===0)return[n("result.fields",{de:"Eine Erfassung braucht mindestens ein Feld ('result.fields').",en:"A record needs at least one field ('result.fields')."})];let t=[],r=new Set;for(let[i,o]of e.entries()){let a=`result.fields[${i}]`;if(typeof o!="object"||o===null||Array.isArray(o)){t.push(n(a,{de:"Ein Feld der Erfassung muss ein Objekt sein.",en:"A field of the record must be an object."}));continue}let l=o,d=l.key;typeof d!="string"||!/^[a-z][a-zA-Z0-9_]*$/.test(d)?t.push(n(`${a}.key`,{de:`Feld-Schl\xFCssel ${JSON.stringify(d)} \u2014 erlaubt sind Buchstaben, Ziffern und _, beginnend mit einem Kleinbuchstaben.`,en:`Field key ${JSON.stringify(d)} \u2014 letters, digits and _ are allowed, starting with a lowercase letter.`})):r.has(d)?t.push(n(`${a}.key`,{de:`Feld-Schl\xFCssel "${d}" ist doppelt.`,en:`Field key "${d}" is duplicated.`})):r.add(d);let c=typeof d=="string"?`"${d}"`:`Nr. ${i+1}`,u=typeof d=="string"?`"${d}"`:`no. ${i+1}`;if(hy(l.type)||t.push(n(`${a}.type`,{de:`Feld ${c}: Typ ${JSON.stringify(l.type)} \u2014 erlaubt: ${hf.join(", ")}.`,en:`Field ${u}: type ${JSON.stringify(l.type)} \u2014 allowed: ${hf.join(", ")}.`})),TN(l.label)||t.push(n(`${a}.label`,{de:`Feld ${c} braucht ein Label in beiden Sprachen ({ de, en }).`,en:`Field ${u} needs a label in both languages ({ de, en }).`})),Mr(l.writes)||t.push(n(`${a}.writes`,{de:`Feld ${c} schreibt in keinen Vorgangs-Schl\xFCssel ('writes') \u2014 ein Wert, den niemand lesen kann, geh\xF6rt nicht in eine Erfassung.`,en:`Field ${u} writes to no process key ('writes') \u2014 a value nobody can read does not belong in a record.`})),l.type==="enum"){let m=Array.isArray(l.options)?l.options:[],y=m.map(k=>k.key);(m.length<2||y.some(k=>typeof k!="string"||k.length===0)||new Set(y).size!==y.length||m.some(k=>!TN(k.label)))&&t.push(n(`${a}.options`,{de:`Feld ${c} (Auswahl) braucht mindestens 2 Optionen mit eindeutigen Schl\xFCsseln und Labels in beiden Sprachen.`,en:`Field ${u} (choice) needs at least 2 options with unique keys and labels in both languages.`}))}else l.options!==void 0&&t.push(n(`${a}.options`,{de:`Feld ${c}: 'options' gibt es nur bei Typ 'enum'.`,en:`Field ${u}: 'options' exists only for type 'enum'.`}));if(l.min!==void 0&&(l.type!=="number"||typeof l.min!="number"||!Number.isInteger(l.min))&&t.push(n(`${a}.min`,{de:`Feld ${c}: 'min' gibt es nur bei Typ 'number', als ganze Zahl.`,en:`Field ${u}: 'min' exists only for type 'number', as a whole number.`})),l.evidence!==void 0&&typeof l.evidence!="boolean"&&t.push(n(`${a}.evidence`,{de:`Feld ${c}: 'evidence' ist true oder false.`,en:`Field ${u}: 'evidence' is true or false.`})),l.evidenceFrom!==void 0){let m=typeof l.min=="number"?l.min:0;(l.type!=="number"||l.evidence!==!0||typeof l.evidenceFrom!="number"||!Number.isInteger(l.evidenceFrom)||l.evidenceFrom<=m)&&t.push(n(`${a}.evidenceFrom`,{de:`Feld ${c}: 'evidenceFrom' gibt es nur bei Typ 'number' mit 'evidence', als ganze Zahl \xFCber dem Minimum (${m}) \u2014 sonst g\xE4lte der Nachweis immer.`,en:`Field ${u}: 'evidenceFrom' exists only for type 'number' with 'evidence', as a whole number above the minimum (${m}) \u2014 otherwise the proof would always apply.`}))}if(l.suggest!==void 0){let m=l.suggest,y=typeof m=="object"&&m!==null?m.kind:void 0;y==="form"&&"address"in m&&Object.keys(m).length===2&&(!we(m.address)||fn(m.address))||y==="siblingRank"&&Object.keys(m).length===1&&l.type==="number"||t.push({field:`${a}.suggest`,code:Ze.recordSuggest,message:{de:`Feld ${c}: Vorschlag ${JSON.stringify(l.suggest)} \u2014 erlaubt: { kind: 'form', address: '$node.<formular>.admission.<export>' } oder { kind: 'siblingRank' } (nur bei Typ 'number'); bekannte Arten: ${gy.join(", ")}.`,en:`Field ${u}: suggestion ${JSON.stringify(l.suggest)} \u2014 allowed: { kind: 'form', address: '$node.<form>.admission.<export>' } or { kind: 'siblingRank' } (only for type 'number'); known kinds: ${gy.join(", ")}.`}})}let p=Object.keys(l).filter(m=>!Aw.includes(m));p.length>0&&t.push(n(a,{de:`Feld ${c}: unbekannte Angabe ${p.map(m=>`'${m}'`).join(", ")}; erlaubt: ${Aw.join(", ")}.`,en:`Field ${u}: unknown entry ${p.map(m=>`'${m}'`).join(", ")}; allowed: ${Aw.join(", ")}.`}))}return t}s(wY,"recordFieldIssues");function kY(e,n,t){let r=[],i=n.options;if(e==="choice"){let o=Array.isArray(i)?i:[],a=o.map(l=>l.key);(o.length<2||a.some(l=>typeof l!="string"||l.length===0)||new Set(a).size!==a.length)&&r.push({field:"result.options",code:Ze.choiceOptions,message:{de:`Ein Auswahl-Ergebnis braucht mindestens 2 Optionen mit eindeutigen Schl\xFCsseln, erhalten ${JSON.stringify(a)}.`,en:`A choice result needs at least 2 options with unique keys, got ${JSON.stringify(a)}.`}})}else i!==void 0&&r.push({field:"result.options",code:Ze.choiceOptions,message:{de:`'result.options' gibt es nur bei 'choice' \u2014 ${e==="recommendation"?"eine Empfehlung hat die festen Tendenzen Positiv/Neutral/Negativ":"ein Freitext hat keine Auswahl"}.`,en:`'result.options' exists only for 'choice' \u2014 ${e==="recommendation"?"a recommendation has the fixed leanings Positive/Neutral/Negative":"a free text has no choice"}.`}});if(e==="pricedItem"){let o=n.item;if(!Mr(o))r.push({field:"result.item",code:Ze.pricedItemMissingItem,message:{de:"Ein Preispositions-Ergebnis nennt den Artikel, den es bepreist \u2014 'result.item' (der Schl\xFCssel des Artikels, z. B. 'tuition') fehlt.",en:"A priced-item result names the article it prices \u2014 'result.item' (the article's key, e.g. 'tuition') is missing."}});else if(t.billingItemKeys!==void 0&&!t.billingItemKeys.has(o))r.push({field:"result.item",code:Ze.pricedItemUnknownItem,message:{de:`'result.item' "${o}" \u2014 kein Artikel dieses Mandanten tr\xE4gt diesen Schl\xFCssel (bekannt: ${[...t.billingItemKeys].join(", ")||"keine"}).`,en:`'result.item' "${o}" \u2014 no article of this school has this key (known: ${[...t.billingItemKeys].join(", ")||"none"}).`}});else if(t.offerProgram===null)r.push({field:"result.item",code:Ze.pricedItemOfferWithoutProgram,message:{de:`'result.item' "${o}" \u2014 das Angebot ist keinem Programm zugeordnet, also geh\xF6rt kein Artikel zu ihm; dem Angebot ein Programm geben.`,en:`'result.item' "${o}" \u2014 the offer is not assigned to a program, so no article belongs to it; give the offer a program.`}});else if(t.offerProgram!==void 0&&!t.offerProgram.billingItemKeys.has(o)){let l=t.offerProgram;r.push({field:"result.item",code:Ze.pricedItemNotInProgram,message:{de:`'result.item' "${o}" \u2014 der Artikel ist dem Programm \u201E${l.nameDe}\u201C des Angebots nicht zugeordnet (zugeordnet: ${[...l.billingItemKeys].join(", ")||"keine"}); unter Finanzen \u2192 Artikel zuordnen, direkt oder \xFCber ein Paket.`,en:`'result.item' "${o}" \u2014 the article is not assigned to the offer's program "${l.nameDe}" (assigned: ${[...l.billingItemKeys].join(", ")||"none"}); assign it under Finance \u2192 articles, directly or through a package.`}})}let a=n.label;(typeof a!="object"||a===null||!Mr(a.de)||!Mr(a.en))&&r.push({field:"result.label",code:Ze.labelMissing,message:{de:"Ein Preispositions-Ergebnis braucht einen Namen f\xFCr seinen Wert in beiden Sprachen ('result.label', z. B. { de: 'Schulgeld mit Erm\xE4\xDFigung', en: 'Tuition after reduction' }) \u2014 so hei\xDFt er im Workflow und in der Verdrahtung.",en:"A priced-item result needs a name for its value in both languages ('result.label', e.g. { de: 'Schulgeld mit Erm\xE4\xDFigung', en: 'Tuition after reduction' }) \u2014 that is what it is called in the workflow and in the wiring."}})}else n.item!==void 0&&r.push({field:"result.item",code:Ze.itemOnNonPricedItem,message:{de:`'result.item' gibt es nur bei 'pricedItem' \u2014 ein ${e}-Ergebnis bepreist keinen Artikel.`,en:`'result.item' exists only for 'pricedItem' \u2014 a ${e} result prices no article.`}});if(e==="record"?(r.push(...wY(n.fields)),n.writes!==void 0&&r.push({field:"result.writes",code:Ze.writesOnProse,message:{de:"Eine Erfassung schreibt je Feld ('fields[].writes'), nie als Ganzes ('result.writes').",en:"A record writes per field ('fields[].writes'), never as a whole ('result.writes')."}}),n.label!==void 0&&r.push({field:"result.label",code:Ze.unknownField,message:{de:"Eine Erfassung benennt ihre Werte je Feld ('fields[].label'), nicht als Ganzes ('result.label').",en:"A record names its values per field ('fields[].label'), not as a whole ('result.label')."}})):n.fields!==void 0&&r.push({field:"result.fields",code:Ze.fieldsOnNonRecord,message:{de:`'result.fields' gibt es nur bei 'record' \u2014 ein ${e}-Ergebnis hat keine Felder.`,en:`'result.fields' exists only for 'record' \u2014 a ${e} result has no fields.`}}),e==="reduction"?(Mr(n.writes)||r.push({field:"result.writes",code:Ze.reductionPrices,message:{de:"Eine Reduktion schreibt ihren Betrag in einen Vorgangs-Schl\xFCssel vom Typ reduction ('result.writes') \u2014 sonst l\xE4se ihn kein Preis.",en:"A reduction writes its amount to a process key of type reduction ('result.writes') \u2014 otherwise no price would read it."}}),Mr(n.prices)||r.push({field:"result.prices",code:Ze.reductionPrices,message:{de:"Eine Reduktion nennt den abgeleiteten Preis, den sie senkt ('result.prices') \u2014 gegen seine Untergrenze wird der Betrag bei der Eingabe gepr\xFCft.",en:"A reduction names the derived price it lowers ('result.prices') \u2014 the amount is checked against its lower bound on entry."}})):n.prices!==void 0&&r.push({field:"result.prices",code:Ze.pricesOnNonReduction,message:{de:`'result.prices' gibt es nur bei 'reduction' \u2014 ein ${e}-Ergebnis senkt keinen Preis.`,en:`'result.prices' exists only for 'reduction' \u2014 a ${e} result lowers no price.`}}),n.writes!==void 0&&(e==="freetext"||e==="recommendation")&&r.push({field:"result.writes",code:Ze.writesOnProse,message:{de:`'result.writes' gibt es nur bei Ergebnissen mit Wert (Auswahl, Preisposition) \u2014 ein ${e}-Ergebnis bleibt im Chat und schreibt nichts in den Vorgang.`,en:`'result.writes' exists only for results with a value (choice, priced item) \u2014 a ${e} result stays in the chat and writes nothing to the process.`}}),e==="freetext"&&n.textRequired!==void 0&&r.push({field:"result.textRequired",code:Ze.textRequiredOnFreetext,message:{de:"'textRequired' auf einem Freitext-Ergebnis \u2014 der Text eines Freitexts ist immer Pflicht; die Angabe entfernen.",en:"'textRequired' on a free-text result \u2014 the text of a free text is always required; remove the entry."}}),n.chat===void 0)r.push({field:"result.chat",code:Ze.chatMissing,message:{de:"Ein Aufgaben-Ergebnis steht nur im Chat \u2014 'result.chat' fehlt: 'all', 'team:<Gruppe>' oder einen Kanal des Workflows angeben.",en:"A task result appears only in the chat \u2014 'result.chat' is missing: give 'all', 'team:<group>' or a channel of the workflow."}});else{let o=n.chat,a=typeof o=="string"?As(o):null;o==="external"||a===null?r.push({field:"result.chat",code:Ze.chatExternal,message:{de:`'result.chat' ${JSON.stringify(o)} \u2014 ein Aufgaben-Ergebnis bleibt intern: erlaubt sind 'all', 'team:<Gruppe>' oder ein Kanal des Workflows, nie 'external'.`,en:`'result.chat' ${JSON.stringify(o)} \u2014 a task result stays internal: 'all', 'team:<group>' or a channel of the workflow are allowed, never 'external'.`}}):a.kind==="channel"&&!t.channelKeys.has(a.channelKey)&&r.push({field:"result.chat",code:Ze.chatUnknownChannel,message:{de:`'result.chat' "${a.channelKey}" ist weder 'all' noch 'team:<Gruppe>' noch ein Kanal des Workflows (bekannt: ${[...t.channelKeys].join(", ")||"keine"}).`,en:`'result.chat' "${a.channelKey}" is neither 'all' nor 'team:<group>' nor a channel of the workflow (known: ${[...t.channelKeys].join(", ")||"none"}).`}})}return r.push(...$N(n,["kind","options","textRequired","chat","item","label","writes","fields","prices"],{de:"Aufgaben-Ergebnis",en:"task result"})),r}s(kY,"recordedIssues");function RN(e,n,t={channelKeys:new Set}){if(n===void 0)return[];if(e!=="task")return[{field:"result",code:Ze.onApproval,message:{de:`'result' gilt nur f\xFCr die Art 'task' \u2014 eine '${e}' wird durch ihr Votum abgeschlossen, nicht durch ein Ergebnis.`,en:`'result' applies only to the kind 'task' \u2014 an '${e}' is completed by its vote, not by a result.`}}];if(typeof n!="object"||n===null||Array.isArray(n))return[{field:"result",code:Ze.unknownKind,message:{de:`'result' muss ein Objekt mit 'kind' sein; bekannte Arten: ${xs.join(", ")}.`,en:`'result' must be an object with 'kind'; known kinds: ${xs.join(", ")}.`}}];let r=n;return _I(r.kind)?r.kind==="appointment"?yY(r):kY(r.kind,r,t):[{field:"result.kind",code:Ze.unknownKind,message:{de:`Unbekannte Ergebnisart ${JSON.stringify(r.kind)}; bekannte Arten: ${xs.join(", ")}.`,en:`Unknown result kind ${JSON.stringify(r.kind)}; known kinds: ${xs.join(", ")}.`}}]}s(RN,"taskResultIssues");var Ew=60;function ai(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"error"}}s(ai,"error");function bY(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"warning"}}s(bY,"warning");function IN(e){return Array.isArray(e.tasks)?e.tasks:[]}s(IN,"tasksOf");function PN(e,n){return(Array.isArray(e.optionalActions)?e.optionalActions:[]).filter(r=>r.action==="spawnTasks"&&Array.isArray(r.tasks)&&r.tasks.includes(n))}s(PN,"spawnActionsOf");function ON(e,n){return PN(e,n).map(t=>String(t.key)).sort()}s(ON,"bindingsOf");function NN(e,n){let t=[],r=IN(e),i=new Map;for(let o of r){if(o.appointment===void 0)continue;let a=typeof o.key=="string"?o.key:"?",l=`nodes.${e.id}.tasks.${a}`,d={de:`Terminaufgabe "${a}" (Knoten "${e.id}")`,en:`Appointment task "${a}" (node "${e.id}")`},c=o.appointment,p=typeof c=="object"&&c!==null&&Object.keys(c).every(T=>T==="of"||T==="dueDaysAfterEnd")&&typeof c.of=="string"?c.of:void 0,m=p===void 0?void 0:r.find(T=>T.key===p),y=m?.result;if(p===void 0||m===void 0||y?.kind!=="appointment")t.push(ai(`${l}.appointment.of`,{de:`[workItems/appointmentOfUnknown] ${d.de} braucht 'appointment: { of, dueDaysAfterEnd }', und 'of' nennt eine Aufgabe desselben Knotens, die mit einem Termin abschlie\xDFt (result.kind 'appointment'); erhalten ${JSON.stringify(o.appointment)}.`,en:`[workItems/appointmentOfUnknown] ${d.en} needs 'appointment: { of, dueDaysAfterEnd }', and 'of' names a task of the same node that ends with an appointment (result.kind 'appointment'); got ${JSON.stringify(o.appointment)}.`}));else{i.set(p,(i.get(p)??0)+1);let T=m.blocks,b=[...["when","optional"].filter(R=>m[R]!==void 0),...typeof T?.node=="string"&&T.node!==e.id?["blocks"]:[]];b.length>0&&t.push(ai(`nodes.${e.id}.tasks.${p}.${b[0]}`,{de:`[workItems/appointmentTaskShape] "${p}" bucht den Termin f\xFCr ${d.de} und tr\xE4gt ${b.map(R=>R==="blocks"?"ein knoten\xFCbergreifendes 'blocks'":`'${R}'`).join(", ")} \u2014 fiele sie ohne Buchung weg oder \xFCberlebte sie ihren Knoten, wartete die Terminaufgabe f\xFCr immer bzw. f\xE4nde die Buchung keine Terminaufgabe mehr.`,en:`[workItems/appointmentTaskShape] "${p}" books the appointment for ${d.en} and carries ${b.map(R=>R==="blocks"?"a cross-node 'blocks'":`'${R}'`).join(", ")} \u2014 if it dropped out without a booking or outlived its node, the appointment task would wait forever or the booking would find no appointment task any more.`}));for(let R of PN(e,p))R.repeatable!==!0&&t.push(ai(`nodes.${e.id}.optionalActions.${String(R.key)}.repeatable`,{de:`[workItems/appointmentActionRepeatable] Die optionale Aktion "${String(R.key)}" legt "${p}" an, die den Termin f\xFCr ${d.de} bucht, und ist nicht 'repeatable: true'. Eine Absage beendet die Runde; ohne zweite Runde lie\xDFe sich die Aktion nie wieder ausl\xF6sen, und eine Entscheidung, die auf sie wartet (requiresOneOf), bliebe h\xE4ngen.`,en:`[workItems/appointmentActionRepeatable] The optional action "${String(R.key)}" creates "${p}", which books the appointment for ${d.en}, and is not 'repeatable: true'. A cancellation ends the round; without a second round the action could never be triggered again, and a decision waiting for it (requiresOneOf) would hang.`}));ON(e,a).join(",")!==ON(e,p).join(",")&&t.push(ai(`${l}.appointment.of`,{de:`[workItems/appointmentTaskBinding] ${d.de} geh\xF6rt zu anderen optionalen Aktionen als "${p}", die ihren Termin bucht \u2014 beide Zeilen sind eine Runde: entweder beide in derselben Aktion (spawnTasks) oder beide in keiner.`,en:`[workItems/appointmentTaskBinding] ${d.en} belongs to different optional actions than "${p}", which books its appointment \u2014 both rows are one round: either both in the same action (spawnTasks) or both in none.`}))}let k=c?.dueDaysAfterEnd;(typeof k!="number"||!Number.isInteger(k)||k<0||k>Ew)&&t.push(ai(`${l}.appointment.dueDaysAfterEnd`,{de:`[workItems/appointmentTaskDue] ${d.de}: 'dueDaysAfterEnd' ist eine ganze Zahl von 0 bis ${Ew} \u2014 die Tage nach dem Terminende, bis die Aufgabe f\xE4llig ist; erhalten ${JSON.stringify(k)}.`,en:`[workItems/appointmentTaskDue] ${d.en}: 'dueDaysAfterEnd' is a whole number from 0 to ${Ew} \u2014 the days after the appointment ends until the task is due; got ${JSON.stringify(k)}.`})),o.params?.dueInDays!==void 0&&t.push(ai(`${l}.params.dueInDays`,{de:`[workItems/appointmentTaskDue] ${d.de} tr\xE4gt 'params.dueInDays' neben 'appointment.dueDaysAfterEnd' \u2014 eine Terminaufgabe ist ab dem Terminende f\xE4llig, nie ab ihrer Anlage.`,en:`[workItems/appointmentTaskDue] ${d.en} carries 'params.dueInDays' next to 'appointment.dueDaysAfterEnd' \u2014 an appointment task is due from the end of the appointment, never from its creation.`}));let g=o.result,v=["when","optional","familyRequest","reads","locksEvidence"].filter(T=>o[T]!==void 0).map(T=>`'${T}'`),E=typeof o.blocks?.node=="string"&&o.blocks.node!==e.id,A=s(T=>[...o.kind!=="task"?["'kind: approval'"]:[],...g===void 0||!Pi(g.kind)?[T==="de"?"kein erfasstes Ergebnis (Feedback)":"no recorded result (feedback)"]:[],...v,...E?[T==="de"?"ein knoten\xFCbergreifendes 'blocks'":"a cross-node 'blocks'"]:[]],"shapeFaults");A("de").length>0&&t.push(ai(`${l}.appointment`,{de:`[workItems/appointmentTaskShape] ${d.de}: ${A("de").join(", ")} \u2014 eine Terminaufgabe ist eine Aufgabe, die mit ihrem Feedback (Freitext, Empfehlung, Auswahl) abschlie\xDFt, und sie entsteht, weil der Termin entsteht: ohne Bedingung, nicht optional, keine Nachforderung, ohne Belege (nichts l\xE4sst sie ungebunden neu entstehen) und an ihrem Knoten.`,en:`[workItems/appointmentTaskShape] ${d.en}: ${A("en").join(", ")} \u2014 an appointment task is a task that ends with its feedback (free text, recommendation, choice), and it exists because the appointment exists: no condition, not optional, no follow-up request, no evidence (nothing lets it be created again unbound) and on its own node.`}));let I=o.result?.chat,_=o.assign?.group;typeof I=="string"&&I.startsWith("team:")&&typeof _=="string"&&I!==`team:${_}`&&t.push(bY(`${l}.result.chat`,{de:`[workItems/appointmentChatUnreadable] ${d.de} schreibt ihr Feedback in "${I}", geh\xF6rt aber dem Team "${_}" \u2014 die Gastgeberin bzw. der Gastgeber (ein Mitglied von "${_}") kann das eigene Feedback dort wom\xF6glich nicht lesen. 'team:${_}' oder 'all' w\xE4hlen, oder das Team als Mitglied des Chats sicherstellen.`,en:`[workItems/appointmentChatUnreadable] ${d.en} writes its feedback to "${I}", but belongs to the team "${_}" \u2014 the host (a member of "${_}") may not be able to read their own feedback there. Choose 'team:${_}' or 'all', or make sure the team is a member of the chat.`}));for(let T of n)for(let b of IN(T)){let R=b.blocks;R?.templateKey!==a||(typeof R.node=="string"?R.node:T.id)!==e.id||t.push(ai(`nodes.${T.id}.tasks.${String(b.key)}.blocks.templateKey`,{de:`[workItems/appointmentTaskBlocked] Task "${String(b.key)}" (Knoten "${T.id}") h\xE4lt ${d.de} zur\xFCck \u2014 eine Terminaufgabe wartet nur auf ihren Termin (abgeleitet aus 'appointment.of'); ein 'blocks' auf sie entf\xE4llt.`,en:`[workItems/appointmentTaskBlocked] Task "${String(b.key)}" (node "${T.id}") holds back ${d.en} \u2014 an appointment task only waits for its appointment (derived from 'appointment.of'); a 'blocks' on it is dropped.`}))}}for(let[o,a]of i)a<2||t.push(ai(`nodes.${e.id}.tasks.${o}`,{de:`[workItems/appointmentOfTwice] ${a} Terminaufgaben auf Knoten "${e.id}" geh\xF6ren zum Termin von "${o}" \u2014 ein Termin hat eine Terminaufgabe.`,en:`[workItems/appointmentOfTwice] ${a} appointment tasks on node "${e.id}" belong to the appointment of "${o}" \u2014 an appointment has one appointment task.`}));return t}s(NN,"appointmentTaskIssues");var vY="optionalAction:";function _N(e){return`${vY}${e}:trigger`}s(_N,"optionalActionTriggerActionId");var xY="processDecide";function CN(e){let n=e.optionalActions;return n==null?[]:(Array.isArray(n)||F(`[optionalAction/corrupt-section] node's 'optionalActions' is ${typeof n}, not an array \u2014 corrupt pinned graph (publish stores the section as authored)`),n)}s(CN,"optionalActionBindings");function DN(e){return CN(e).map(n=>({id:_N(n.key),kind:"internal",label:n.label,surface:xY,placement:"overflow",superUserOnly:!0}))}s(DN,"optionalActionTriggers");function FN(e){let n=new Set;for(let t of CN(e))if(t.action==="spawnTasks")for(let r of t.tasks??[])n.add(r);return n}s(FN,"referencedTaskTemplateKeys");var At={notOptionalAction:"[workItems/familyRequestNotOptionalAction]",notTask:"[workItems/familyRequestNotTask]",closedOtherwise:"[workItems/familyRequestClosedOtherwise]",blocks:"[workItems/familyRequestBlocks]",noDeadline:"[workItems/familyRequestNoDeadline]",fields:"[workItems/familyRequestFields]",unknownField:"[workItems/familyRequestUnknownField]",shape:"[workItems/familyRequestShape]",twicePerAction:"[workItems/familyRequestTwicePerAction]",deadlock:"[workItems/familyRequestOnlyWayButAsked]"};function Et(e,n,t){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:{de:`${n} ${t.de}`,en:`${n} ${t.en}`},severity:"error"}}s(Et,"issue");function SY(e,n,t){return e.flatMap(r=>(Array.isArray(r.tasks)?r.tasks:[]).filter(i=>{let o=i.blocks,a=typeof o?.node=="string"?o.node:r.id;return o?.templateKey===t&&a===n}).map(i=>({nodeId:r.id,key:String(i.key)})))}s(SY,"blockersOf");function LN(e){let{graph:n,node:t,task:r}=e,i=r.familyRequest;if(i===void 0)return[];let o=typeof r.key=="string"?r.key:"?",a=`nodes.${t.id}.tasks.${o}`,l={de:`Task "${o}" auf Knoten \u201E${Oe(n,t.id,"de")}\u201C (${t.id})`,en:`Task "${o}" on node "${Oe(n,t.id,"en")}" (${t.id})`},d=[];if(typeof i!="object"||i===null||Array.isArray(i))return[Et(`${a}.familyRequest`,At.shape,{de:`${l.de}: 'familyRequest' muss ein Objekt { fields } oder { from } sein.`,en:`${l.en}: 'familyRequest' must be an object { fields } or { from }.`})];let c=Object.keys(i).filter(k=>k!=="fields"&&k!=="from");c.length>0&&d.push(Et(`${a}.familyRequest.${c[0]}`,At.shape,{de:`${l.de}: 'familyRequest' kennt nur 'fields' oder 'from', nicht ${c.map(k=>`'${k}'`).join(", ")} \u2014 was angefordert wird und der Text an die Familie werden beim Ausl\xF6sen gew\xE4hlt.`,en:`${l.en}: 'familyRequest' only knows 'fields' or 'from', not ${c.map(k=>`'${k}'`).join(", ")} \u2014 what is requested and the text to the family are chosen when the action is triggered.`}));let{fields:u,from:p}=i;u===void 0==(p===void 0)&&d.push(Et(`${a}.familyRequest`,At.shape,{de:`${l.de}: 'familyRequest' nennt genau eines \u2014 'fields' (die anforderbaren Felder) oder 'from' (das Formular, dessen Dateifelder alle zur Wahl stehen).`,en:`${l.en}: 'familyRequest' names exactly one \u2014 'fields' (the fields that can be requested) or 'from' (the form whose file fields are all available).`})),e.onTrigger.has(o)||d.push(Et(`${a}.familyRequest`,At.notOptionalAction,{de:`${l.de} fordert bei der Familie an, geh\xF6rt aber zu keiner optionalen Aktion (spawnTasks) \u2014 nur deren Ausl\xF6sen \xF6ffnet die Anfrage an die Familie.`,en:`${l.en} requests from the family but belongs to no optional action (spawnTasks) \u2014 only triggering one opens the request to the family.`})),r.kind!=="task"&&d.push(Et(`${a}.kind`,At.notTask,{de:`${l.de} fordert bei der Familie an und muss die Art 'task' haben, nicht ${JSON.stringify(r.kind)}.`,en:`${l.en} requests from the family and must have the kind 'task', not ${JSON.stringify(r.kind)}.`}));for(let k of["result","when","locksEvidence","gatesNode"])r[k]!==void 0&&d.push(Et(`${a}.${k}`,At.closedOtherwise,{de:`${l.de} wartet auf die Familie und erledigt sich mit ihrer Antwort \u2014 '${k}' passt nicht dazu.`,en:`${l.en} waits for the family and completes with their answer \u2014 '${k}' does not fit that.`}));r.blocks!==void 0&&d.push(Et(`${a}.blocks`,At.blocks,{de:`${l.de} wartet auf die Familie und darf nichts zur\xFCckhalten ('blocks') \u2014 sie h\xE4lt ihren Knoten schon als Aufgabe einer optionalen Aktion.`,en:`${l.en} waits for the family and must not hold anything back ('blocks') \u2014 as the task of an optional action it already holds its node.`}));for(let k of SY(n.nodes,t.id,o))d.push(Et(`nodes.${k.nodeId}.tasks.${k.key}.blocks`,At.blocks,{de:`Task "${k.key}" auf Knoten "${k.nodeId}" h\xE4lt ${l.de} zur\xFCck \u2014 eine Nachforderung darf nie zur\xFCckgehalten werden: zur\xFCckgehalten h\xE4tte sie keine Frist und k\xF6nnte mit der Antwort der Familie nicht erledigt werden.`,en:`Task "${k.key}" on node "${k.nodeId}" holds back ${l.en} \u2014 a follow-up request must never be held back: held back, it would have no deadline and could not be completed by the family's answer.`}));let m=r.params?.dueInDays;if((typeof m!="number"||!Number.isInteger(m)||m<1)&&d.push(Et(`${a}.params.dueInDays`,At.noDeadline,{de:`${l.de} fordert bei der Familie an und braucht eine Frist in ganzen Tagen ('params.dueInDays' \u2265 1) \u2014 sie ist die Frist der Familie und Anlass der Erinnerung.`,en:`${l.en} requests from the family and needs a deadline in whole days ('params.dueInDays' \u2265 1) \u2014 it is the family's deadline and the reason for the reminder.`})),u===void 0)return d;if(!Array.isArray(u)||u.length===0)return d.push(Et(`${a}.familyRequest.fields`,At.fields,{de:`${l.de}: 'familyRequest.fields' muss mindestens ein Feld eines Formulars nennen \u2014 oder statt dessen 'from' das Formular, dann stehen alle seine Dateifelder zur Wahl.`,en:`${l.en}: 'familyRequest.fields' must name at least one field of a form \u2014 or 'from' the form instead, then all its file fields are available.`})),d;let y=new Set;for(let k of u){if(!we(k))continue;let g=se(k);if(y.has(g)){d.push(Et(`${a}.familyRequest.fields`,At.fields,{de:`${l.de}: 'familyRequest.fields' nennt ${Ve(n,k,"de")} mehrfach.`,en:`${l.en}: 'familyRequest.fields' names ${Ve(n,k,"en")} more than once.`}));continue}y.add(g),fn(k)||d.push(Et(`${a}.familyRequest.fields`,At.unknownField,{de:`${l.de}: 'familyRequest.fields' nennt ${Ve(n,k,"de")} \u2014 anfordern l\xE4sst sich nur ein Feld eines Formulars ($node.<formular>.admission.<feld>).`,en:`${l.en}: 'familyRequest.fields' names ${Ve(n,k,"en")} \u2014 only a field of a form ($node.<form>.admission.<field>) can be requested.`}))}return d}s(LN,"familyRequestIssues");function MN(e){let n=new Set((Array.isArray(e.tasks)?e.tasks:[]).flatMap(r=>r.familyRequest!==void 0&&typeof r.key=="string"?[r.key]:[]));return(Array.isArray(e.optionalActions)?e.optionalActions:[]).flatMap((r,i)=>{if(r.action!=="spawnTasks"||!Array.isArray(r.tasks))return[];let o=r.tasks.filter(a=>typeof a=="string"&&n.has(a));return o.length<=1?[]:[Et(`nodes.${e.id}.optionalActions.${i}.tasks`,At.twicePerAction,{de:`Optionale Aktion \u201E${String(r.key)}\u201C auf Knoten "${e.id}" startet ${o.length} Nachforderungen (${o.join(", ")}) \u2014 ein Ausl\xF6sen fragt die Familie nach EINER Sache; h\xF6chstens eine Nachforderung je Aktion.`,en:`Optional action "${String(r.key)}" on node "${e.id}" starts ${o.length} follow-up requests (${o.join(", ")}) \u2014 one trigger asks the family for ONE thing; at most one follow-up request per action.`})]})}s(MN,"familyRequestActionIssues");function qN(e,n){let t=e.nodes,r=new Map;for(let a of t)if(!(a.type!=="completenessCheck"||!Array.isArray(a.requires)))for(let l of a.requires)fn(l)&&r.set(se(l),l);if(r.size===0)return[];let i=s(a=>{let l=oi(n,a);return l===void 0||l!==null&&l.kind==="entered"&&l.type==="docRef"},"isFileField"),o=s(a=>{let{fields:l,from:d}=a??{};return Array.isArray(l)?l.filter(fn):!we(d)||d.scope!=="node"?[]:[...r.values()].filter(c=>c.owner===d.owner&&i(c))},"offeredBy");return t.flatMap(a=>{let l=Array.isArray(a.requiresOneOf)?a.requiresOneOf:[];if(l.length!==1)return[];let c=(Array.isArray(a.optionalActions)?a.optionalActions:[]).find(p=>p.key===l[0]);return c===void 0||!Array.isArray(c.tasks)?[]:(Array.isArray(a.tasks)?a.tasks:[]).flatMap(p=>{if(p.familyRequest===void 0||!c.tasks.includes(p.key))return[];let m=o(p.familyRequest).filter(y=>r.has(se(y)));return m.length===0?[]:[{...Et(`nodes.${a.id}.requiresOneOf`,At.deadlock,{de:`Auf Knoten \u201E${Oe(e,a.id,"de")}\u201C (${a.id}) ist die Nachforderung \u201E${String(c.key)}\u201C der einzige Weg durch 'requiresOneOf', und eine Vollst\xE4ndigkeitspr\xFCfung fragt dieselben Felder an (${m.map(y=>Ve(e,y,"de")).join(", ")}). Ist deren Anfrage offen, lassen sich diese Felder nicht nachfordern \u2014 die Entscheidung bliebe gesperrt. Eine zweite Aktion in 'requiresOneOf' oder andere Felder l\xF6sen das.`,en:`On node "${Oe(e,a.id,"en")}" (${a.id}) the follow-up request "${String(c.key)}" is the only way through 'requiresOneOf', and a completeness check asks for the same fields (${m.map(y=>Ve(e,y,"en")).join(", ")}). While its request is open, these fields cannot be requested \u2014 the decision would stay locked. A second action in 'requiresOneOf' or other fields solve this.`}),severity:"warning"}]})})}s(qN,"familyRequestDeadlockWarnings");var Tw={key:!0,kind:!0,title:!0,assign:!0,gatesNode:!0,blocks:!0,completableIf:!0,result:!0,when:!0,onConditionReturn:!0,reads:!0,locksEvidence:!0,description:!0,documents:!0,formView:!0,familyRequest:!0,optional:!0,appointment:!0,params:!0};function AY(e){let n=He(e);return new Map((typeof n.workItemTemplates=="function"?n.workItemTemplates(e):[]).map(t=>[t.key,t]))}s(AY,"intrinsicTemplatesOf");function KN(e,n,t){if(t!==void 0&&typeof t!="string")return null;let r=t??n,i=e.nodes.find(l=>l.id===r);if(i===void 0)return null;let o=i,a=He(i);return{node:o,composedKeys:new Set((Array.isArray(o.tasks)?o.tasks:[]).map(l=>l.key).filter(l=>typeof l=="string")),intrinsicByKey:AY(i),refuse:s(l=>typeof a.refuseBlocksTarget=="function"?a.refuseBlocksTarget(i,l):null,"refuse")}}s(KN,"resolveBlocksTargetNode");function EY(e){let n=new Map;for(let r of Qt(e.nodes)){let i=n.get(r.source)??[];i.push(r.target),n.set(r.source,i)}let t=new Map;return r=>{let i=t.get(r);if(i!==void 0)return i;let o=new Set,a=[...n.get(r)??[]];for(;a.length>0;){let l=a.shift();o.has(l)||(o.add(l),a.push(...n.get(l)??[]))}return t.set(r,o),o}}s(EY,"reachability");function jN(e){let n=[],t=new Map;for(let o of e.nodes){let a=o;for(let l of Array.isArray(a.tasks)?a.tasks:[]){let d=typeof l.key=="string"?l.key:void 0,c=l.blocks;if(d===void 0||typeof c?.templateKey!="string")continue;let u=typeof c.node=="string"?c.node:o.id;t.set(`${o.id}::${d}`,`${u}::${c.templateKey}`)}}let r=new Map,i=s((o,a)=>{if(r.get(o)==="done")return;if(r.get(o)==="visiting"){let d=[...a.slice(a.indexOf(o)),o],[c,u]=o.split("::");n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${c}.tasks.${u}.blocks`,reason:{de:`[workItems/blocksCycle] Zyklus im 'blocks'-Graphen: ${d.map(p=>`"${p.replace("::"," \xB7 ")}"`).join(" \u2192 ")} \u2014 jedes Mitglied w\xFCrde auf ein anderes warten, keines w\xFCrde je frei.`,en:`[workItems/blocksCycle] Cycle in the 'blocks' graph: ${d.map(p=>`"${p.replace("::"," \xB7 ")}"`).join(" \u2192 ")} \u2014 every member would wait for another, none would ever be released.`},severity:"error"});return}r.set(o,"visiting");let l=t.get(o);l!==void 0&&t.has(l)&&i(l,[...a,o]),r.set(o,"done")},"walk");for(let o of t.keys())i(o,[]);return n}s(jN,"checkBlocksCycles");function TY(e){let{requiresOneOf:n,optionalActions:t}=e;if(!Array.isArray(n)||!Array.isArray(t))return new Set;let r=new Set(n.filter(o=>typeof o=="string")),i=new Set;for(let o of t)if(!(typeof o.key!="string"||!r.has(o.key)||!Array.isArray(o.tasks)))for(let a of o.tasks)typeof a=="string"&&i.add(a);return i}s(TY,"tasksOfRequiresOneOf");function BN(e){if(typeof e!="object"||e===null)return!1;let{de:n,en:t}=e;return typeof n=="string"&&n.trim().length>0&&typeof t=="string"&&t.trim().length>0}s(BN,"isFilledBilingual");var $Y=["blocks","gatesNode","locksEvidence","completableIf"];function RY(e,n){let t=[],r={de:`Task "${n.key}" (Knoten "${n.nodeId}")`,en:`Task "${n.key}" (node "${n.nodeId}")`},i=e.optional;(!(typeof i=="object"&&i!==null&&Object.keys(i).every(d=>d==="skipLabel"))||!BN(i.skipLabel))&&t.push(Wn(`${n.base}.optional.skipLabel`,{de:`[workItems/optionalSkipLabel] ${r.de} ist optional, braucht daf\xFCr '{ skipLabel: { de, en } }' \u2014 die Worte des Knopfs, mit dem die zust\xE4ndige Person ohne Ergebnis abschlie\xDFt (\u201EKeine Einsch\xE4tzung abgeben"); erhalten ${JSON.stringify(i)}.`,en:`[workItems/optionalSkipLabel] ${r.en} is optional and needs '{ skipLabel: { de, en } }' for that \u2014 the words of the button the responsible person uses to finish without a result ("Give no assessment"); got ${JSON.stringify(i)}.`})),e.kind!=="task"&&t.push(Wn(`${n.base}.optional`,{de:`[workItems/optionalOnApproval] ${r.de} ist eine Freigabe \u2014 optional ist nur eine Aufgabe; eine Freigabe schlie\xDFt mit ihrem Urteil.`,en:`[workItems/optionalOnApproval] ${r.en} is an approval \u2014 only a task can be optional; an approval ends with its verdict.`}));let a=e.result;(a===void 0||typeof a.kind!="string"||!CI({kind:a.kind,writes:a.writes}))&&t.push(Wn(`${n.base}.optional`,{de:`[workItems/optionalNeedsProseResult] ${r.de} ist optional, schlie\xDFt aber ${a===void 0?"ohne Ergebnis":`mit einem ${String(a.kind)}-Ergebnis${a.writes!==void 0?" mit Wert":""}`} \u2014 optional ist nur eine Aufgabe mit Freitext, Empfehlung oder einer Auswahl ohne 'writes': einen Wert, den ein sp\xE4terer Schritt liest, g\xE4be es dann nie.`,en:`[workItems/optionalNeedsProseResult] ${r.en} is optional but ends ${a===void 0?"without a result":`with a ${String(a.kind)} result${a.writes!==void 0?" with a value":""}`} \u2014 only a task with free text, a recommendation or a choice without 'writes' can be optional: a value a later step reads would then never arrive.`}));let l=$Y.filter(d=>e[d]!==void 0);return l.length>0&&t.push(Wn(`${n.base}.${l[0]}`,{de:`[workItems/optionalHolds] ${r.de} ist optional und tr\xE4gt ${l.map(d=>`'${d}'`).join(", ")} \u2014 auf eine optionale Aufgabe wartet nichts: sie h\xE4lt keinen Schritt zur\xFCck. Entweder optional oder zur\xFCckhaltend.`,en:`[workItems/optionalHolds] ${r.en} is optional and carries ${l.map(d=>`'${d}'`).join(", ")} \u2014 nothing waits for an optional task: it holds no step back. Either optional or holding back.`})),n.requiredByRule&&t.push(Wn(`${n.base}.optional`,{de:`[workItems/optionalInRequiresOneOf] ${r.de} ist optional, geh\xF6rt aber zu einer Aktion, die 'requiresOneOf' verlangt \u2014 \u201EKeine Einsch\xE4tzung abgeben" w\xFCrde die Regel erf\xFCllen, ohne dass etwas geschehen ist.`,en:`[workItems/optionalInRequiresOneOf] ${r.en} is optional but belongs to an action that 'requiresOneOf' requires \u2014 "Give no assessment" would satisfy the rule without anything having happened.`})),t}s(RY,"optionalTaskIssues");function Wn(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"error"}}s(Wn,"issue");function VN(e,n){let t=[],r=EY(e),i=new Set(Qs(e).map(o=>o.key));t.push(...qN(e,n));for(let o of e.nodes){let a=o,l=FN(a);t.push(...MN(a));let d=TY(a);t.push(...NN(a,e.nodes));for(let c of Array.isArray(a.tasks)?a.tasks:[]){let u=typeof c.key=="string"?c.key:"?",p=`nodes.${o.id}.tasks.${u}`,m=c.kind,y=c.result,k=c.blocks,g=typeof k?.node=="string"&&k.node!==o.id?k.node:void 0;if(typeof k?.templateKey=="string"){let R=typeof k.node=="string"?k.node:o.id,q=e.nodes.find(Y=>Y.id===R),J=(Array.isArray(q?.tasks)?q.tasks:[]).find(Y=>Y.key===k.templateKey)?.blocks;typeof J?.node=="string"&&J.node!==R&&t.push(Wn(`${p}.blocks.templateKey`,{de:`[workItems/blocksCrossNodeTask] Task "${u}" auf Knoten "${o.id}" h\xE4lt "${k.templateKey}" auf Knoten "${R}" zur\xFCck \u2014 das ist selbst eine knoten\xFCbergreifende Aufgabe, die ihren Knoten \xFCberlebt; zur\xFCckgehalten k\xF6nnte sie nach dessen Verlassen weder bearbeitet noch freigegeben werden. Nur Aufgaben, die an ihrem Knoten bleiben, und intrinsische Vorlagen sind Ziele.`,en:`[workItems/blocksCrossNodeTask] Task "${u}" on node "${o.id}" holds back "${k.templateKey}" on node "${R}" \u2014 that is itself a cross-node task that outlives its node; held back, it could be neither worked nor released after the node is left. Only tasks that stay on their node and intrinsic templates are targets.`}))}if(g!==void 0){let R=g;e.nodes.some(q=>q.id===R)&&!r(o.id).has(R)&&t.push(Wn(`${p}.blocks.node`,{de:`[workItems/blocksTargetNotAfter] Task "${u}" auf Knoten "${o.id}" blockiert Knoten "${R}", der von hier aus nicht erreichbar ist \u2014 die Aufgabe entst\xFCnde erst, wenn ihr Ziel schon hinter dem Prozess liegt. Ziel ist derselbe Knoten oder ein sp\xE4terer.`,en:`[workItems/blocksTargetNotAfter] Task "${u}" on node "${o.id}" blocks node "${R}", which cannot be reached from here \u2014 the task would only be created when its target is already behind the process. The target is the same node or a later one.`})),(y===void 0||!Pi(y.kind))&&t.push(Wn(`${p}.blocks.node`,{de:`[workItems/crossNodeBlocksNeedsResult] Task "${u}" auf Knoten "${o.id}" blockiert einen anderen Knoten ("${R}"), hat aber kein 'result' \u2014 eine knoten\xFCbergreifende Aufgabe \xFCberlebt ihren Knoten und wird \xFCber ihr Ergebnis abgeschlossen (Freitext, Empfehlung oder Auswahl).`,en:`[workItems/crossNodeBlocksNeedsResult] Task "${u}" on node "${o.id}" blocks another node ("${R}") but has no 'result' \u2014 a cross-node task outlives its node and is completed through its result (free text, recommendation or choice).`})),l.has(u)&&t.push(Wn(`${p}.blocks.node`,{de:`[optionalAction/crossNodeBlocks] Task "${u}" geh\xF6rt zu einer optionalen Aktion (spawnTasks) auf Knoten "${o.id}" und darf keinen anderen Knoten blockieren \u2014 ihre Zeilen sind die Runde der Aktion.`,en:`[optionalAction/crossNodeBlocks] Task "${u}" belongs to an optional action (spawnTasks) on node "${o.id}" and must not block another node \u2014 its rows are the round of the action.`}))}for(let R of RN(String(m),y,{channelKeys:i,...n?.billingItemKeys!==void 0?{billingItemKeys:n.billingItemKeys}:{},...n?.offerProgram!==void 0?{offerProgram:n.offerProgram}:{}}))t.push(Wn(`${p}.${R.field}`,{de:`${R.code} ${R.message.de} (Task "${u}" auf Knoten "${o.id}").`,en:`${R.code} ${R.message.en} (task "${u}" on node "${o.id}").`}));let v=c.when,E=s((R,q,P)=>{!we(q)||fn(q)||t.push(Wn(R,{de:`[workItems/evidenceNotFormField] ${P} auf Task "${u}" (Knoten "${o.id}") nennt ${Ve(e,q,"de")} \u2014 Bedingung und Belege einer Aufgabe sind Felder eines Formulars ($node.<formular>.admission.<feld>).`,en:`[workItems/evidenceNotFormField] ${P} on task "${u}" (node "${o.id}") names ${Ve(e,q,"en")} \u2014 the condition and evidence of a task are fields of a form ($node.<form>.admission.<field>).`}))},"notFormField");v!==void 0?(E(`${p}.when`,v,"'when'"),c.onConditionReturn!=="respawn"&&c.onConditionReturn!=="stayClosed"&&t.push(Wn(`${p}.onConditionReturn`,{de:`[workItems/whenNeedsOnConditionReturn] Task "${u}" (Knoten "${o.id}") hat eine Bedingung, aber kein 'onConditionReturn' ('respawn' | 'stayClosed') \u2014 was bei der R\xFCckkehr der Bedingung geschieht, muss entschieden sein.`,en:`[workItems/whenNeedsOnConditionReturn] Task "${u}" (node "${o.id}") has a condition but no 'onConditionReturn' ('respawn' | 'stayClosed') \u2014 what happens when the condition returns must be decided.`}))):c.onConditionReturn!==void 0&&t.push(Wn(`${p}.onConditionReturn`,{de:`[workItems/whenNeedsOnConditionReturn] 'onConditionReturn' ohne 'when' auf Task "${u}" (Knoten "${o.id}") \u2014 ohne Bedingung kehrt nichts zur\xFCck.`,en:`[workItems/whenNeedsOnConditionReturn] 'onConditionReturn' without 'when' on task "${u}" (node "${o.id}") \u2014 without a condition nothing returns.`}));let A=c.reads;if(A!==void 0)if(!Array.isArray(A))t.push(Wn(`${p}.reads`,{de:`[workItems/readsUnknownField] 'reads' auf Task "${u}" (Knoten "${o.id}") muss eine Liste von Feldadressen sein.`,en:`[workItems/readsUnknownField] 'reads' on task "${u}" (node "${o.id}") must be a list of field addresses.`}));else for(let[R,q]of A.entries())E(`${p}.reads.${R}`,q,"'reads'");let I=c.locksEvidence,_=s((R,q)=>t.push(Wn(`${p}.locksEvidence`,{de:`[workItems/${R}] Task "${u}" (Knoten "${o.id}") ${q.de}`,en:`[workItems/${R}] Task "${u}" (node "${o.id}") ${q.en}`})),"lockIssue");I!==void 0&&I!==!0&&_("locksEvidenceNotTrue",{de:`tr\xE4gt 'locksEvidence' ${JSON.stringify(I)} \u2014 nur 'true' ist erlaubt; ohne Sperre entf\xE4llt das Feld.`,en:`carries 'locksEvidence' ${JSON.stringify(I)} \u2014 only 'true' is allowed; without a lock the field is dropped.`}),I===!0&&(A===void 0&&v===void 0&&_("locksEvidenceWithoutEvidence",{de:"sperrt seine Belege, hat aber weder 'reads' noch 'when' \u2014 es gibt nichts, worauf die Entscheidung beruht.",en:"locks its evidence but has neither 'reads' nor 'when' \u2014 there is nothing the decision rests on."}),(y===void 0||!Pi(y.kind))&&_("locksEvidenceNeedsRecordedResult",{de:"sperrt seine Belege, schlie\xDFt aber nicht mit einem erfassten Ergebnis (Freitext, Empfehlung, Auswahl) \u2014 nur eine Entscheidung, die das Team wieder\xF6ffnen kann, darf Belege sperren (ein Termin bleibt gebucht).",en:"locks its evidence but does not end with a recorded result (free text, recommendation, choice) \u2014 only a decision the team can reopen may lock evidence (an appointment stays booked)."}),l.has(u)&&_("locksEvidenceOnOptionalAction",{de:"geh\xF6rt zu einer optionalen Aktion (spawnTasks) \u2014 ihre Zeilen sind die Runde der Aktion, wieder\xF6ffnen l\xE4sst sie sich nicht; Belege sperrt nur eine Knotenaufgabe.",en:"belongs to an optional action (spawnTasks) \u2014 its rows are the round of the action and cannot be reopened; only a node task locks evidence."})),t.push(...LN({graph:e,node:a,task:c,onTrigger:l,specCtx:n}));let T=Object.keys(c).filter(R=>!Object.hasOwn(Tw,R));T.length>0&&t.push(Wn(`${p}.${T[0]}`,{de:`[workItems/unknownKey] Task "${u}" (Knoten "${o.id}") tr\xE4gt ${T.map(R=>`'${R}'`).join(", ")} \u2014 kein Feld einer Aufgabe. Erlaubt: ${Object.keys(Tw).join(", ")}. (Checklisten gibt es nicht mehr: Text als 'description', mehrere Arbeitsschritte sind mehrere Aufgaben.)`,en:`[workItems/unknownKey] Task "${u}" (node "${o.id}") carries ${T.map(R=>`'${R}'`).join(", ")} \u2014 not a field of a task. Allowed: ${Object.keys(Tw).join(", ")}. (Checklists no longer exist: text goes in 'description', several work steps are several tasks.)`}));let b=c.description;b!==void 0&&!BN(b)&&t.push(Wn(`${p}.description`,{de:`[workItems/descriptionInvalid] 'description' auf Task "${u}" (Knoten "${o.id}") braucht Text in beiden Sprachen ({ de, en }), erhalten ${JSON.stringify(b)}.`,en:`[workItems/descriptionInvalid] 'description' on task "${u}" (node "${o.id}") needs text in both languages ({ de, en }), got ${JSON.stringify(b)}.`})),c.optional!==void 0&&t.push(...RY(c,{key:u,nodeId:o.id,base:p,requiredByRule:d.has(u)}))}}return t}s(VN,"checkNodeTasks");function UN(e){let n=e.indexOf(":"),t=n===-1?"":e.slice(0,n),r=n===-1?"":e.slice(n+1).trim();if(t==="artifact"&&r.length>0)return{kind:t,key:r};let i=Zr(r);return(t==="field"||t==="document")&&i!==null?{kind:t,address:i}:le("INVALID",{de:`Dokument-Verweis "${e}" ist ung\xFCltig \u2014 erwartet artifact:<Slot-Schl\xFCssel>, field:$node.<Formular>.admission.<Feld> oder document:$node.<Knoten>.document.`,en:`Document reference "${e}" is invalid \u2014 expected artifact:<slot key>, field:$node.<form>.admission.<field> or document:$node.<node>.document.`})}s(UN,"parseTaskDocumentRef");function $w(e){return e.kind==="artifact"?`artifact:${e.key}`:`${e.kind}:${se(e.address)}`}s($w,"taskDocumentId");function li(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"error"}}s(li,"issue");function GN(e){return Array.isArray(e.tasks)?e.tasks:[]}s(GN,"tasksOf");function IY(e){let n=new Map;for(let t of e){let{id:r,artifacts:i}=t;for(let o of Array.isArray(i)?i:[])typeof o?.key=="string"&&n.set(o.key,[...n.get(o.key)??[],{nodeId:r,slot:o}])}return n}s(IY,"artifactSlotDeclarations");function OY(e){return e.flatMap(n=>{let{id:t,artifacts:r}=n;return(Array.isArray(r)?r:[]).filter(i=>!qf(i?.type)).map(i=>({nodeId:String(t),slotKey:String(i?.key),type:JSON.stringify(i?.type??null)}))})}s(OY,"unknownArtifactSlotTypes");function zN(e){let n=[];for(let{nodeId:t,slotKey:r,type:i}of OY(e.nodes))n.push(li(`nodes.${t}.artifacts.${r}.type`,{de:`[artifact/unknownType] Knoten "${t}" deklariert den Dokument-Slot \u201E${r}" mit der Art ${i} \u2014 erlaubt sind ${js.join(", ")}.`,en:`[artifact/unknownType] Node "${t}" declares the document slot "${r}" with the type ${i} \u2014 allowed are ${js.join(", ")}.`}));for(let[t,r]of IY(e.nodes))for(let i of r.slice(1))n.push(li(`nodes.${i.nodeId}.artifacts`,{de:`[governedDocument/slotKeyTaken] Knoten "${i.nodeId}" deklariert den Dokument-Slot \u201E${t}", den schon "${r[0].nodeId}" deklariert \u2014 jeder Slot-Schl\xFCssel geh\xF6rt genau einem Knoten.`,en:`[governedDocument/slotKeyTaken] Node "${i.nodeId}" declares the document slot "${t}", which "${r[0].nodeId}" already declares \u2014 every slot key belongs to exactly one node.`}));return n}s(zN,"checkArtifactSlotKeys");function WN(e){if(!Array.isArray(e)||e.length===0)return null;let n=[];for(let t of e){let r=typeof t=="object"&&t!==null?t:{},i=Object.keys(r).sort().join(",");if(r.kind==="artifact"&&i==="key,kind"&&typeof r.key=="string"&&r.key.length>0)n.push({kind:"artifact",key:r.key});else if((r.kind==="field"||r.kind==="document")&&i==="address,kind")n.push({kind:r.kind,address:r.address});else return null}return n}s(WN,"authoredRefs");function PY(e){return e.scope==="node"&&(e.key===wl||e.key===Ts||e.key===$s)&&e.path===void 0}s(PY,"isDocumentAddress");function YN(e){let n=[];for(let t of e.nodes)for(let r of GN(t)){if(r.documents===void 0)continue;let i=typeof r.key=="string"?r.key:"?",o=`nodes.${t.id}.tasks.${i}.documents`,a={de:`Task "${i}" (Knoten "${t.id}")`,en:`Task "${i}" (node "${t.id}")`},l=WN(r.documents);if(l===null){n.push(li(o,{de:`[workItems/documentsInvalid] 'documents' auf ${a.de} muss eine nicht leere Liste von { kind: 'artifact', key } (eigener Slot), { kind: 'field', address } (Dateifeld eines Formulars) oder { kind: 'document', address } (Dokument eines anderen Knotens) sein, erhalten ${JSON.stringify(r.documents)}.`,en:`[workItems/documentsInvalid] 'documents' on ${a.en} must be a non-empty list of { kind: 'artifact', key } (own slot), { kind: 'field', address } (file field of a form) or { kind: 'document', address } (document of another node), got ${JSON.stringify(r.documents)}.`}));continue}let d=new Set;for(let c of l){if(c.kind!=="artifact"&&!we(c.address))continue;let u=c.kind==="artifact"?$w(c):$w({kind:c.kind,address:c.address});d.has(u)&&n.push(li(o,{de:`[workItems/documentsDuplicate] ${a.de} verweist zweimal auf ${u}.`,en:`[workItems/documentsDuplicate] ${a.en} refers to ${u} twice.`})),d.add(u),c.kind==="artifact"&&!sO(t,c.key)&&n.push(li(o,{de:`[workItems/documentsUnknownArtifact] ${a.de} verweist auf das Dokument "${c.key}", aber der Knoten deklariert keinen solchen Slot \u2014 das Dokument eines anderen Knotens ist { kind: 'document', address: $node.<knoten>.document }.`,en:`[workItems/documentsUnknownArtifact] ${a.en} refers to the document "${c.key}", but the node declares no such slot \u2014 the document of another node is { kind: 'document', address: $node.<node>.document }.`})),c.kind==="field"&&!fn(c.address)&&n.push(li(o,{de:`[workItems/documentsInvalid] ${a.de}: ein Feld-Dokument nennt ein Feld eines Formulars ($node.<formular>.admission.<feld>), nicht ${Ve(e,c.address,"de")}.`,en:`[workItems/documentsInvalid] ${a.en}: a field document names a field of a form ($node.<form>.admission.<field>), not ${Ve(e,c.address,"en")}.`})),c.kind==="document"&&!PY(c.address)&&n.push(li(o,{de:`[workItems/documentsInvalid] ${a.de}: ein Dokument eines anderen Knotens ist dessen ganzes Dokument ($node.<knoten>.document), nicht ${se(c.address)}.`,en:`[workItems/documentsInvalid] ${a.en}: a document of another node is that node's whole document ($node.<node>.document), not ${se(c.address)}.`}))}}return n}s(YN,"checkTaskDocuments");function HN(e,n){let t=[];for(let r of e.nodes)for(let i of GN(r)){let o=WN(i.documents);if(o===null)continue;let a=typeof i.key=="string"?i.key:"?",l=`nodes.${r.id}.tasks.${a}.documents`;for(let d of o){if(d.kind!=="field"||!fn(d.address))continue;let c=oi(n,d.address);if(c==null)continue;let u={de:Ve(e,d.address,"de"),en:Ve(e,d.address,"en")},p=Fs("taskDocument",Ds(c));if(p==="repeated"){t.push(li(l,{de:`[workItems/documentsUnknownField] Task "${a}" (Knoten "${r.id}") verweist auf das Feld ${u.de} \u2014 ein Feld in einer Wiederholgruppe ist kein einzelnes Dokument der Anmeldung.`,en:`[workItems/documentsUnknownField] Task "${a}" (node "${r.id}") refers to the field ${u.en} \u2014 a field in a repeated group is not a single document of the application.`}));continue}p==="notDocument"&&t.push(li(l,{de:`[workItems/documentsNotDocument] Task "${a}" (Knoten "${r.id}") verweist auf das Feld ${u.de}, das keine Datei enth\xE4lt \u2014 nur Datei-Felder (docRef) sind Dokumente.`,en:`[workItems/documentsNotDocument] Task "${a}" (node "${r.id}") refers to the field ${u.en}, which holds no file \u2014 only file fields (docRef) are documents.`}))}}return t}s(HN,"checkTaskDocumentFields");var Rw=["form","documents"],NY=/^[a-z][a-zA-Z0-9_-]*$/;function _Y(e){let n=new Map,t=s(r=>{for(let i of[...r.fields,...(r.groups??[]).flatMap(o=>o.fields)])n.set(i.key,i.type==="docRef"?"document":"other");for(let i of r.repeated??[]){n.set(i.key,"other");for(let o of i.itemTemplate)n.set(`${i.key}[].${o.key}`,o.type==="docRef"?"row":"other")}r.subsections?.forEach(t)},"visit");return e.sections.forEach(t),n}s(_Y,"fieldPlaces");function JN(e,n,t){let r=[],i=new Set;return e.forEach((o,a)=>{if(typeof o!="string"||!NY.test(o)){r.push({severity:"error",path:`${t(a)}.key`,code:"view.invalid-key",message:{de:`${n.de}: '${String(o)}' ist kein g\xFCltiger Schl\xFCssel (Kleinbuchstabe am Anfang, dann Buchstaben, Ziffern, - oder _).`,en:`${n.en}: '${String(o)}' is no valid key (a lower-case letter first, then letters, digits, - or _).`}});return}i.has(o)&&r.push({severity:"error",path:`${t(a)}.key`,code:"view.duplicate-key",message:{de:`${n.de}: Der Schl\xFCssel '${o}' kommt doppelt vor.`,en:`${n.en}: the key '${o}' occurs twice.`}}),i.add(o)}),r}s(JN,"keyIssues");function CY(e,n,t){return e==="document"?null:e===void 0?{severity:"error",path:t,code:"view.unknown-field",message:{de:`Ansicht: Das Formular hat kein Feld '${n}'.`,en:`View: the form has no field '${n}'.`}}:e==="row"?{severity:"error",path:t,code:"view.field-in-row",message:{de:`Ansicht: Das Dateifeld '${n}' liegt in einem wiederholten Block und kann nicht einzeln genannt werden.`,en:`View: the file field '${n}' sits in a repeated block and cannot be named on its own.`}}:{severity:"error",path:t,code:"view.not-a-document",message:{de:`Ansicht: Das Feld '${n}' enth\xE4lt keine Datei.`,en:`View: the field '${n}' holds no file.`}}}s(CY,"fieldIssue");function DY(e,n,t){let r=[];Rw.includes(e.key)&&r.push({severity:"error",path:`${n}.key`,code:"view.reserved-key",message:{de:`Der Ansichtsschl\xFCssel '${e.key}' ist f\xFCr die Standardansicht reserviert.`,en:`The view key '${e.key}' is reserved for the standard view.`}});let i=e.groups;i.length===0&&r.push({severity:"error",path:`${n}.groups`,code:"view.empty",message:{de:`Ansicht '${e.key}' hat keine Gruppen.`,en:`View '${e.key}' has no groups.`}}),r.push(...JN(i.map(a=>a.key),{de:`Gruppe der Ansicht '${e.key}'`,en:`Group of view '${e.key}'`},a=>`${n}.groups[${a}]`));let o=new Set;return i.forEach((a,l)=>{let d=`${n}.groups[${l}]`,c=a.fields;c.length===0&&r.push({severity:"error",path:`${d}.fields`,code:"view.empty",message:{de:`Gruppe '${a.key}' der Ansicht '${e.key}' hat keine Felder.`,en:`Group '${a.key}' of view '${e.key}' has no fields.`}}),c.forEach((u,p)=>{let m=`${d}.fields[${p}]`,y=CY(t.get(u),u,m);y!==null&&r.push(y),o.has(u)&&r.push({severity:"error",path:m,code:"view.field-twice",message:{de:`Ansicht '${e.key}': Das Feld '${u}' steht mehrfach; eine Datei hat einen Platz.`,en:`View '${e.key}': the field '${u}' is listed more than once; a file has one place.`}}),o.add(u)})}),r}s(DY,"viewIssues");function FY(e){if(!Array.isArray(e))return"views";for(let[n,t]of e.entries()){let r=t?.groups;if(!Array.isArray(r))return`views[${n}].groups`;for(let[i,o]of r.entries()){let a=o?.fields;if(!Array.isArray(a)||a.some(l=>typeof l!="string"))return`views[${n}].groups[${i}].fields`}}return null}s(FY,"malformedAt");function QN(e){let n=e.views;if(n===void 0)return[];let t=FY(n);if(t!==null)return[{severity:"error",path:t,code:"view.malformed",message:{de:`${t} hat nicht die Form einer Ansicht: views ist eine Liste von { key, label, groups }, groups eine Liste von { key, label, fields }, fields eine Liste von Feldschl\xFCsseln.`,en:`${t} is not shaped like a view: views is a list of { key, label, groups }, groups a list of { key, label, fields }, fields a list of field keys.`}}];let r=_Y(e);return[...JN(n.map(i=>i.key),{de:"Ansicht",en:"View"},i=>`views[${i}]`),...n.flatMap((i,o)=>DY(i,`views[${o}]`,r))]}s(QN,"formViewIssues");function sp(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"error"}}s(sp,"issue");function ZN(e,n,t,r){let i=e;if(i===null||typeof i!="object"||typeof i.form!="string"||typeof i.key!="string")return[sp(n,{de:`[workItems/formViewInvalid] 'formView' auf ${t.de} muss { form: <Formularknoten>, key: <Ansicht> } sein.`,en:`[workItems/formViewInvalid] 'formView' on ${t.en} must be { form: <form node>, key: <view> }.`})];let o=r?.formViewKeysByFormNode;if(o===void 0)return[];let a=o.get(i.form);return a===void 0?[sp(n,{de:`[workItems/formViewUnknownForm] ${t.de} nennt das Formular "${i.form}", aber kein Formularknoten hei\xDFt so.`,en:`[workItems/formViewUnknownForm] ${t.en} names the form "${i.form}", but no form node has that id.`})]:a.has(i.key)||Rw.includes(i.key)?[]:[sp(n,{de:`[workItems/formViewUnknown] ${t.de} nennt die Ansicht "${i.key}", aber das Formular "${i.form}" hat keine solche Ansicht.`,en:`[workItems/formViewUnknown] ${t.en} names the view "${i.key}", but the form "${i.form}" has no such view.`})]}s(ZN,"viewIssues");function XN(e,n){let t=[];for(let r of e.nodes){if(r.formView!==void 0){let i={de:`Knoten "${r.id}"`,en:`node "${r.id}"`};r.type!=="decision"?t.push(sp(`nodes.${r.id}.formView`,{de:`[workItems/formViewInvalid] ${i.de}: 'formView' am Knoten gilt nur f\xFCr eine Entscheidung; eine Aufgabe tr\xE4gt ihre eigene.`,en:`[workItems/formViewInvalid] ${i.en}: 'formView' on a node applies to a decision only; a task carries its own.`})):t.push(...ZN(r.formView,`nodes.${r.id}.formView`,i,n))}for(let i of Array.isArray(r.tasks)?r.tasks:[]){if(i.formView===void 0)continue;let o=String(i.key);t.push(...ZN(i.formView,`nodes.${r.id}.tasks.${o}.formView`,{de:`Task "${o}" (Knoten "${r.id}")`,en:`Task "${o}" (node "${r.id}")`},n))}}return t}s(XN,"checkTaskFormViews");var _t="traeger",e_={de:"Tr\xE4ger",en:"Provider"};function Xs(e){let n=e.inputs?.[_t];return n?.kind==="literal"&&typeof n.value=="string"&&n.value.length>0?n.value:null}s(Xs,"traegerKeyOfNode");var ap={name:"input.traeger.name",address:"input.traeger.anschrift"},mhe=Object.values(ap);var n_="governedDocument",To="prepareDocument",Ml="prepareDocument:revision",qr="releaseApproval",$o="documentResponse",Kr="responseCheck",lp="returnSigned";var t_="requestApproval";var r_="issueDocument",i_="correctInPlace",o_="rescindAndReissue",dp="requestChange";var ea="releaseArtifact",ut="signingRecovery",cp="resendESignature",Ro="switchToPaper";var Iw=new Set([To,Ml]),s_=["pending","producing","producingHeld","deferred","awaitingApproval","awaitingResponse","responseReturned","responseInCheck","awaitingSignature","signatureStalled","done"],up=["upload","resolver","template","none"],Io=1,Oo=366,di="responseDueInDays";function Ow(e){let n=e.inputs?.[di];return n?.kind==="literal"&&ql(n.value)?n.value:void 0}s(Ow,"responseDueInDaysForVocabulary");function ql(e){return typeof e=="number"&&Number.isInteger(e)&&e>=Io&&e<=Oo}s(ql,"isValidResponseDueInDays");var fp=["generatedAt","responseDueInDays","countersignature"],Po=["release","none"],pp=["confirm","signedUpload","signedUploadChecked","eSignature"];var LY={kind:"confirm",acceptOutcomeId:"accepted",declineOutcomeId:"declined",outcomeSemantics:{accept:"granted",decline:"rejected"},acceptEvent:"userTaskResolved",producesResponseArtifact:!1,declineIsAnswer:!0,acceptStatus:"accepted",checksReturn:!1,issuesBy:"paper",defaultLabels:{accept:{de:"Annehmen",en:"Accept"},decline:{de:"Ablehnen",en:"Decline"}}},a_={kind:"signedUpload",acceptOutcomeId:"signed",declineOutcomeId:"absage",outcomeSemantics:{accept:"other",decline:"rejected"},acceptEvent:"userTaskResolved",producesResponseArtifact:!0,declineIsAnswer:!1,acceptStatus:"signed",checksReturn:!1,issuesBy:"paper",defaultLabels:{accept:{de:"Unterschrieben zur\xFCcksenden",en:"Return signed"},decline:{de:"Ablehnen",en:"Decline"}}},l_={...a_,kind:"signedUploadChecked",acceptEvent:"contractEvent",checksReturn:!0},MY={...l_,kind:"eSignature",issuesBy:"provider"},ci={confirm:LY,signedUpload:a_,signedUploadChecked:l_,eSignature:MY};function Bi(e){let n=e.responseStrategy;if(typeof n=="string"&&n in ci)return ci[n];F(`governedDocument node "${e.id}" declares no valid responseStrategy (got ${JSON.stringify(n)}) \u2014 publish validation should have blocked this; corrupt pinned graph`)}s(Bi,"responseStrategyOf");function mp(e){if(e.type!==n_||e.production!=="resolver")return!1;let n=e.responseStrategy;return typeof n=="string"&&n in ci?ci[n].acceptEvent==="contractEvent":!1}s(mp,"isFamilySignedContractNode");function Kl(e){return e.label}s(Kl,"governedDocTitle");function Pw(e){return e.approval==="release"?t_:r_}s(Pw,"submitActionId");function d_(e,n,t){return{key:n,recipient:"internal",title:t,unlocks:[Pw(e)],gatesNode:!0,advancesNode:!0}}s(d_,"producerTemplate");function qY(e){return e.titles?.respond??e.label}s(qY,"responseTitle");var na={de:"\u27E8Titel fehlt\u27E9",en:"\u27E8title missing\u27E9"};function Nw(e){let n=Bi(e),t=[];if(e.production!=="none"&&t.push(d_(e,To,e.titles?.prepare??na),d_(e,Ml,e.titles?.revise??na)),e.approval==="release"&&t.push({key:qr,recipient:"internal",title:e.titles?.approve??na,unlocks:[],verdictResolved:!0,gatesNode:!0,advancesNode:!0}),t.push({key:$o,recipient:"external",title:qY(e),unlocks:n.producesResponseArtifact?[n.checksReturn?lp:n.acceptOutcomeId,n.declineOutcomeId,dp]:[n.acceptOutcomeId,n.declineOutcomeId],advancesNode:!0,...Ow(e)!==void 0?{dueInDays:Ow(e)}:{}}),n.checksReturn&&t.push({key:Kr,recipient:"internal",title:e.titles?.check??na,unlocks:[],verdictResolved:!0,gatesNode:!1,advancesNode:!0}),n.issuesBy==="provider"){let r=Kl(e);t.push({key:ut,recipient:"internal",title:{de:`${r.de}: elektronische Unterschrift kl\xE4ren`,en:`${r.en}: resolve the e-signature`},unlocks:[cp,Ro],gatesNode:!1,advancesNode:!1})}return t}s(Nw,"governedDocIntrinsicTemplates");function KY(e){e.production==="none"&&F(`governedDocSlot: node "${e.id}" has production 'none' \u2014 it governs no artifact slot`);let n=e.artifacts??[];n.length!==1&&F(`governedDocSlot: node "${e.id}" declares ${n.length} artifact slots \u2014 exactly ONE is required (publish validation [governedDocument/slotContract])`);let t=n[0];return(typeof t.key!="string"||t.key.length===0)&&F(`governedDocSlot: node "${e.id}" declares an artifact slot without a key \u2014 corrupt pinned graph`),t}s(KY,"governedDocSlot");function hp(e){return KY(e).key}s(hp,"governedDocSlotKey");var kr="processFooter";var gp="countersign",_w="countersign",c_="countersigned",u_="countersigning",f_="countersigned";var p_={de:"Vertrag gegenzeichnen",en:"Countersign the contract"},jl=["scan","eSignature"],yp="service_provider:1",m_=["countersigning","awaitingSignature","signatureStalled","done"],h_={de:"Elektronische Gegenzeichnung kl\xE4ren",en:"Resolve the electronic countersignature"};function g_(e){return{de:`[countersign/traegerSignatoryMissing] Die Schule zeichnet elektronisch gegen, aber f\xFCr ${e} ist keine Unterschriftsperson hinterlegt, die unterschreiben kann (Rechtstr\xE4ger \u2192 signatoryUserKey, aktives Personal der Schule).`,en:`[countersign/traegerSignatoryMissing] The school countersigns electronically, but no signatory who can sign is on file for ${e} (legal entity \u2192 signatoryUserKey, active staff of the school).`}}s(g_,"traegerSignatoryMissingReason");function Zt(e,n,t){return{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${n}`,reason:t,severity:"error"}}s(Zt,"issue");function wp(e,n){return e.nodes.filter(t=>{let r=t.contract;return t.type==="countersign"&&we(r)&&r.scope==="node"&&r.owner===n})}s(wp,"countersignersOf");function Bl(e){return e.signing==="eSignature"}s(Bl,"isElectronic");function jY(e,n){if(n===void 0||n.sendable||!Bl(e))return[];let t=e.label?.de??e.id,r=e.label?.en||e.id;return[Zt(e,"signing",{de:`[countersign/eSignatureNeedsProvider] \u201E${t}\u201C zeichnet elektronisch gegen, aber die Schule kann nicht senden: ${n.reason.de}`,en:`[countersign/eSignatureNeedsProvider] "${r}" countersigns electronically, but the school cannot send: ${n.reason.en}`})]}s(jY,"countersignProviderIssues");function BY(e,n,t){if(t.scope!=="node")return[];let r=e.nodes.find(o=>o.id===t.owner);if(r===void 0)return[];let i=[];return mp(r)||i.push("sourceNotCheckedContract"),wp(e,r.id).some(o=>o.id!==n)&&i.push("twice"),i}s(BY,"countersignContractRefusals");function y_(e){let n=e.inputs?.dueInDays;return n?.kind==="literal"&&typeof n.value=="number"&&Number.isInteger(n.value)&&n.value>=1?n.value:void 0}s(y_,"validDueInDays");function VY(e,n,t){let r=e.label?.de??e.id,i=e.label?.en||e.id,o=e.signing;if(o!==void 0&&!jl.includes(o))return[Zt(e,"signing",{de:`[countersign/unknownSigning] \u201E${r}\u201C: signing ist scan oder eSignature (gefunden: ${JSON.stringify(o)}).`,en:`[countersign/unknownSigning] "${i}": signing is scan or eSignature (found: ${JSON.stringify(o)}).`})];let a=e.assign?.[ut];if(!Bl(e))return a===void 0?[]:[Zt(e,"assign",{de:`[countersign/recoveryAssign] \u201E${r}\u201C zeichnet auf Papier gegen \u2014 \`assign.signingRecovery\` h\xE4lt keine Aufgabe und geh\xF6rt entfernt.`,en:`[countersign/recoveryAssign] "${i}" countersigns on paper \u2014 \`assign.signingRecovery\` holds no task and must be removed.`})];let l=[];return(typeof a!="string"||a.length===0)&&l.push(Zt(e,"assign",{de:`[countersign/recoveryAssign] \u201E${r}\u201C zeichnet elektronisch gegen \u2014 wer eine gescheiterte Gegenzeichnung kl\xE4rt, fehlt: \`assign.signingRecovery\` nennt das Team.`,en:`[countersign/recoveryAssign] "${i}" countersigns electronically \u2014 who resolves a failed countersignature is missing: \`assign.signingRecovery\` names the team.`})),l.push(...UY(e,n,t),...GY(e,n,t),...jY(e,t?.signingProvider)),l}s(VY,"signingIssues");function k_(e,n){let t=e.contract;if(!(!we(t)||t.scope!=="node"))return n.nodes.find(r=>r.id===t.owner)}s(k_,"contractNodeOf");function UY(e,n,t){let r=k_(e,n),i=r===void 0?null:Xs(r),o=i===null?void 0:t?.traeger?.get(i);return o===void 0||o.hasSignatory?[]:[Zt(e,"signing",g_(o.name))]}s(UY,"traegerSignatoryIssues");function GY(e,n,t){let r=k_(e,n);if(r===void 0)return[];let i=t?.resolverDocumentAnchors?.get(r.id);if(i===void 0)return[];let o=e.label?.de??e.id,a=e.label?.en||e.id,l=[];for(let d of i)d.documentAnchors===null?l.push(Zt(e,"signing",{de:`[countersign/eSignatureAnchorMissing] \u201E${o}\u201C zeichnet elektronisch gegen, aber die Vorlage des Generators \u201E${d.pin}\u201C wurde nie auf Unterschriftsanker gelesen \u2014 Vorlage neu hochladen und den Generator neu versiegeln.`,en:`[countersign/eSignatureAnchorMissing] "${a}" countersigns electronically, but the template of generator "${d.pin}" was never read for signature anchors \u2014 upload the template again and seal the generator again.`})):d.documentAnchors.has(yp)||l.push(Zt(e,"signing",{de:`[countersign/eSignatureAnchorMissing] \u201E${o}\u201C zeichnet elektronisch gegen, aber die Vorlage von \u201E${d.pin}\u201C tr\xE4gt keinen Anker /unterschrift:${yp}/ \u2014 der Anbieter f\xE4nde f\xFCr die Schule kein Unterschriftsfeld.`,en:`[countersign/eSignatureAnchorMissing] "${a}" countersigns electronically, but the template of "${d.pin}" carries no anchor /unterschrift:${yp}/ \u2014 the provider would find no signature field for the school.`}));return l}s(GY,"traegerAnchorIssues");var Cw=100;async function zY(e,n){let t=await e.db.query("work_items").withIndex("by_applicationId_and_nodeId",o=>o.eq("context.applicationId",n.applicationId).eq("context.anchor.nodeId",n.node.id)).take(Cw+1);t.length>Cw&&F(`countersign node "${n.node.id}" of ${n.applicationId} holds more than ${Cw} rows`);let r=t.filter(o=>o.isOpen),i=s(o=>{if(o.context.kind!=="admission")return;let a=o.context.anchor;return"templateKey"in a?a.templateKey:void 0},"templateKeyOf");return r.some(o=>i(o)===ut)?"signatureStalled":r.some(o=>i(o)===gp)?"countersigning":Bl(n.node)?"awaitingSignature":"done"}s(zY,"countersignCurrentState");var w_={[u_]:{label:te("Gegenzeichnung","Countersignature"),tone:"teal",phase:{key:"gegenzeichnung",label:te("Gegenzeichnung","Countersignature"),scope:"node"},external:en(te("Vertrag unterschrieben","Contract signed"),"blue",te("Die Schule zeichnet Ihren Vertrag gegen","The school is countersigning your contract"),te("Vielen Dank f\xFCr Ihre Unterschrift. Sobald die Schule gegengezeichnet hat, finden Sie Ihr Exemplar hier.","Thank you for signing. As soon as the school has countersigned, you will find your copy here."))}},b_={inputs:s(()=>[{id:"dueInDays",label:{de:"Frist der Aufgabe (Tage)",en:"Task due in (days)"},type:"number",inspector:"literal-only"}],"inputs"),role:"user-action",effect:"side-effect",outcomes:[{id:c_,label:{de:"Gegengezeichnet",en:"Countersigned"}}],progressDefaults:w_,progressEvents:Mn(w_),notificationEvents:s(()=>[{id:f_,label:{de:"Vertrag gegengezeichnet",en:"Contract countersigned"},audience:"external",required:!0,args:[{key:"applicationId",type:"string",required:!0},{key:"documentTitle",type:"localizedText",required:!0}]}],"notificationEvents"),actions:s(e=>[{id:_w,kind:"internal",label:p_,surface:kr,availableIn:["countersigning"]},...Bl(e)?[{id:Ro,kind:"internal",surface:kr,label:{de:"Auf Papier umstellen",en:"Switch to paper"},availableIn:["signatureStalled"]}]:[]],"actions"),workItemTemplates:s(e=>[{key:gp,recipient:"internal",title:e.titles?.countersign??na,unlocks:[_w],advancesNode:!0,...y_(e)!==void 0?{dueInDays:y_(e)}:{}},...Bl(e)?[{key:ut,recipient:"internal",title:h_,unlocks:[Ro],gatesNode:!1,advancesNode:!1}]:[]],"workItemTemplates"),states:m_,currentState:zY,validate:s((e,n,t)=>{let r=[],i=e.label?.de??e.id,o=e.label?.en||e.id,a=e.assign?.[gp];(typeof a!="string"||a.length===0)&&r.push(Zt(e,"assign",{de:`[countersign/assign] \u201E${i}": wer gegenzeichnet, fehlt \u2014 \`assign.countersign\` nennt das Team.`,en:`[countersign/assign] "${o}": who countersigns is missing \u2014 \`assign.countersign\` names the team.`})),$i(e.titles?.countersign)||r.push(Zt(e,"titles",{de:`[countersign/missingTitle] \u201E${i}": der Titel der Aufgabe fehlt \u2014 \`titles.countersign\` auf Deutsch und Englisch.`,en:`[countersign/missingTitle] "${o}": the task title is missing \u2014 \`titles.countersign\` in German and English.`}));let l=e.inputs?.dueInDays;l!==void 0&&l.kind!=="unset"&&!(l.kind==="literal"&&typeof l.value=="number"&&Number.isInteger(l.value)&&l.value>=1)&&r.push(Zt(e,"inputs.dueInDays",{de:`[countersign/dueInDays] \u201E${i}": dueInDays ist eine ganze Zahl \u2265 1.`,en:`[countersign/dueInDays] "${o}": dueInDays is a whole number \u2265 1.`})),r.push(...VY(e,n,t));let d=e.contract;if(!we(d))return r;let c=BY(n,e.id,d);if(c.length===0)return r;let u=n.nodes.find(p=>d.scope==="node"&&p.id===d.owner);if(c.includes("sourceNotCheckedContract")&&r.push(Zt(e,"contract",{de:`[countersign/sourceNotCheckedContract] \u201E${i}" zeichnet das Dokument von \u201E${u.label?.de??u.id}" (${u.id}) gegen \u2014 gegenzeichnen l\xE4sst sich nur ein erzeugter Vertrag, den die Familie mit verbuchten Unterschriften unterschreibt (governedDocument mit production: resolver und responseStrategy: signedUploadChecked oder eSignature).`,en:`[countersign/sourceNotCheckedContract] "${o}" countersigns the document of "${u.label?.en||u.id}" (${u.id}) \u2014 only a generated contract that the family signs with booked signatures can be countersigned (governedDocument with production: resolver and responseStrategy: signedUploadChecked or eSignature).`})),c.includes("twice")){let p=wp(n,u.id).filter(m=>m.id!==e.id);r.push(Zt(e,"contract",{de:`[countersign/twice] \u201E${i}": \u201E${u.label?.de??u.id}" (${u.id}) wird schon von ${p.map(m=>`"${m.id}"`).join(", ")} gegengezeichnet \u2014 ein Vertrag hat eine Gegenzeichnung.`,en:`[countersign/twice] "${o}": "${u.label?.en||u.id}" (${u.id}) is already countersigned by ${p.map(m=>`"${m.id}"`).join(", ")} \u2014 a contract has one countersignature.`}))}return r},"validate")};function WY(e){return mp(e)?Xs(e):null}s(WY,"traegerSignerOf");var YY=s(e=>e.type==="end"&&So(e)==="approved","isApprovedEnd");function v_(e){let n=[];for(let t of e.nodes){let r=WY(t);if(r===null)continue;let i=wp(e,t.id).map(u=>u.id),o=qO(e,t.id,new Set(i),YY);if(o===null)continue;let a=t.label?.de||t.id,l=t.label?.en||t.id,d={de:`Einen Knoten \u201EUnterschrift (intern)\u201C (countersign) mit contract: $node.${t.id}.contract auf jeden Weg zu einem Ende mit Ergebnis approved setzen.`,en:`Place an "Internal signature" node (countersign) with contract: $node.${t.id}.contract on every path to an end with outcome approved.`},c=i.length===0?{de:`[countersign/missingForContract] \u201E${a}\u201C (${t.id}) erzeugt einen Vertrag, den der Tr\xE4ger \u201E${r}\u201C mitunterschreibt, aber keine Gegenzeichnung nennt ihn \u2014 der Vertrag w\xFCrde nie unterschrieben und nie abgerechnet. ${d.de}`,en:`[countersign/missingForContract] "${l}" (${t.id}) generates a contract the legal entity "${r}" co-signs, but no countersignature names it \u2014 the contract would never be signed and never billed. ${d.en}`}:{de:`[countersign/missingForContract] \u201E${a}\u201C (${t.id}): ein Weg erreicht das Ende \u201E${o}\u201C (Ergebnis approved), ohne durch die Gegenzeichnung ${i.map(u=>`\u201E${u}\u201C`).join(", ")} zu laufen \u2014 dort bliebe der Vertrag ohne Unterschrift des Tr\xE4gers \u201E${r}\u201C und w\xFCrde nie abgerechnet. ${d.de}`,en:`[countersign/missingForContract] "${l}" (${t.id}): a path reaches the end "${o}" (outcome approved) without passing the countersignature ${i.map(u=>`"${u}"`).join(", ")} \u2014 there the contract would lack the signature of the legal entity "${r}" and never be billed. ${d.en}`};n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${t.id}`,reason:c,severity:"error"})}return n}s(v_,"checkCountersignCoverage");function HY(e){let n="error",t=new Map;for(let a of Qt(e.nodes)){let l=t.get(a.source)??[];l.push({id:a.id,target:a.target}),t.set(a.source,l)}let r=[],i=new Set,o=Xf(e.nodes.map(a=>a.id),a=>(t.get(a)??[]).map(({id:l,target:d})=>({target:d,edge:l})));for(let a of o)i.has(a.edge)||(i.add(a.edge),r.push({layer:"GRAPH",kind:"cycle",path:`edge.${a.edge}`,reason:{de:`Zyklus \xFCber Kante ${a.source} \u2192 ${a.target}`,en:`Cycle through edge ${a.source} \u2192 ${a.target}`},severity:n}));return r}s(HY,"checkAcyclic");function JY(e){let n=[],t=new Set(e.nodes.map(i=>i.id)),r="error";for(let i of e.nodes){let o=i.next;if(o)for(let[a,l]of Object.entries(o))t.has(l.to)||n.push({layer:"GRAPH",kind:"routing",path:`node.${i.id}.next.${a}`,reason:{de:`${i.label.de}: next.${a} verweist auf nicht-existenten Knoten '${l.to}'`,en:`${i.label.en}: next.${a} points to a node that does not exist: '${l.to}'`},severity:"error"});if(i.type!=="end"&&!(!i.outcomes||i.outcomes.length===0))for(let a of i.outcomes)(!o||!(a.id in o))&&n.push({layer:"GRAPH",kind:"routing",path:`node.${i.id}.outcome.${a.id}`,reason:{de:`${i.label.de}: Outcome '${a.label.de}' fehlt im next-Mapping`,en:`${i.label.en}: outcome '${a.label.en}' is missing from the next mapping`},severity:r})}return n}s(JY,"checkNextTargets");function QY(e){let n=[];for(let t of e.nodes){let r=t.next;if(!r)continue;let i=Hy(t),o=new Set(i?i.map(a=>a.id):[Bs]);for(let a of Object.keys(r))o.has(a)||n.push({layer:"GRAPH",kind:"unknownOutcome",path:`node.${t.id}.next.${a}`,reason:{de:`${t.label.de}: next-Schl\xFCssel '${a}' ist kein g\xFCltiges Outcome dieses Knotens (erlaubt: ${[...o].join(", ")}) \u2014 die Kante w\xFCrde im Editor verschwinden`,en:`${t.label.en}: next key '${a}' is not a valid outcome of this node (allowed: ${[...o].join(", ")}) \u2014 the edge would disappear in the editor`},severity:"error"})}return n}s(QY,"checkNextOutcomesKnown");function ZY(e){let n=[],t=new Set(Qt(e.nodes).map(o=>o.target)),r=e.nodes.filter(o=>!t.has(o.id));return r.length===0?n.push({layer:"GRAPH",kind:"startEnd",path:"graph",reason:{de:"Kein Start-Knoten",en:"No start node"},severity:"error"}):r.length>1&&n.push({layer:"GRAPH",kind:"startEnd",path:"graph",reason:{de:`Mehrere Start-Knoten (${r.map(o=>o.label.de).join(", ")})`,en:`Multiple start nodes (${r.map(o=>o.label.en).join(", ")})`},severity:"warning"}),e.nodes.filter(o=>o.type==="end").length===0&&n.push({layer:"GRAPH",kind:"startEnd",path:"graph",reason:{de:"Kein End-Knoten",en:"No end node"},severity:"warning"}),n}s(ZY,"checkStartEnd");function XY(e){let n=new Map;for(let r of Qt(e.nodes))n.set(r.source,(n.get(r.source)??0)+1);let t=[];for(let r of e.nodes)r.type!=="end"&&(n.get(r.id)??0)===0&&t.push({layer:"GRAPH",kind:"startEnd",path:`node.${r.id}`,reason:{de:`${r.label.de}: keine ausgehende Kante`,en:`${r.label.en}: no outgoing edge`},severity:"warning"});return t}s(XY,"checkNoOutgoingEdge");function eH(e){return e.nodes.filter(n=>!Jg(n.id)).map(n=>({layer:"GRAPH",kind:"nodeRule",path:`nodes.${n.id}.id`,reason:{de:`[graph/nodeIdFormat] Knoten "${n.id}": eine Knoten-ID ist ein Bezeichner ohne Punkt (${fr.source}), z. B. "reviewEingereicht". Ein Bundle von vor der Umstellung neu exportieren.`,en:`[graph/nodeIdFormat] Node "${n.id}": a node id is an identifier without a dot (${fr.source}), e.g. "reviewSubmitted". Export a bundle from before the change again.`},severity:"error"}))}s(eH,"checkNodeIdFormat");function nH(e){let n=new Set(e.nodes.map(r=>r.id)),t=[];for(let r of Qt(e.nodes))n.has(r.source)||t.push({layer:"GRAPH",kind:"startEnd",path:`edge.${r.id}`,reason:{de:`Kante ${r.id}: Quelle '${r.source}' nicht gefunden`,en:`Edge ${r.id}: source '${r.source}' not found`},severity:"error"}),n.has(r.target)||t.push({layer:"GRAPH",kind:"startEnd",path:`edge.${r.id}`,reason:{de:`Kante ${r.id}: Ziel '${r.target}' nicht gefunden`,en:`Edge ${r.id}: target '${r.target}' not found`},severity:"error"});return t}s(nH,"checkEdgeEndpoints");var tH=new Set(["countersignature"]);function rH(e){let n=[],t=s((r,i)=>{n.push({layer:"GRAPH",kind:"nodeRule",path:r,reason:{de:`[graph/retiredField] ${i.de}`,en:`[graph/retiredField] ${i.en}`},severity:"error"})},"retired");for(let r of e.nodes){let i=r,o={de:`Knoten \u201E${Oe(e,r.id,"de")}\u201C (${r.id})`,en:`Node "${Oe(e,r.id,"en")}" (${r.id})`};for(let[l,d]of Object.entries(i.next??{}))d!==null&&typeof d=="object"&&"emits"in d&&t(`nodes.${r.id}.next.${l}.emits`,{de:`${o.de}: \`next.${l}.emits\` gibt es nicht mehr \u2014 ein Ausgang routet nur; ein Knoten liest Daten \xFCber Adressen in seinen eigenen Feldern.`,en:`${o.en}: \`next.${l}.emits\` no longer exists \u2014 an outcome only routes; a node reads data through addresses in its own fields.`});for(let l of Array.isArray(i.outcomes)?i.outcomes:[])l!==null&&typeof l=="object"&&"emits"in l&&t(`nodes.${r.id}.outcomes.${String(l.id)}.emits`,{de:`${o.de}: \`emits\` am Ausgang "${String(l.id)}" gibt es nicht mehr \u2014 ein Knoten liest Daten \xFCber Adressen in seinen eigenen Feldern.`,en:`${o.en}: \`emits\` on the outcome "${String(l.id)}" no longer exists \u2014 a node reads data through addresses in its own fields.`});"targetFormNodeId"in i&&t(`nodes.${r.id}.targetFormNodeId`,{de:`${o.de}: \`targetFormNodeId\` gibt es nicht mehr \u2014 welches Formular freigeschaltet wird, sagt die Adresse, an die der Eingang \`inputs.target\` gebunden ist ($node.<formular>.admission).`,en:`${o.en}: \`targetFormNodeId\` no longer exists \u2014 the address the input \`inputs.target\` is bound to says which form is unlocked ($node.<form>.admission).`}),"wires"in i&&t(`nodes.${r.id}.wires`,{de:`${o.de}: Datenkanten (\`wires\`) gibt es nicht mehr \u2014 jedes Feld, das Daten eines anderen Knotens liest, tr\xE4gt selbst die volle Adresse ($node.\u2026, $task.\u2026, $derived.\u2026, $env.\u2026).`,en:`${o.en}: data edges (\`wires\`) no longer exist \u2014 every field that reads data of another node carries the full address itself ($node.\u2026, $task.\u2026, $derived.\u2026, $env.\u2026).`});for(let[l,d]of Object.entries(i.inputs??{}))d!==null&&typeof d=="object"&&d.kind==="binding"&&"path"in d&&t(`nodes.${r.id}.inputs.${l}.path`,{de:`${o.de}: Der Eingang \u201E${l}\u201C ist \xFCber einen Pfad (\`path\`) gebunden \u2014 eine Bindung tr\xE4gt die volle Adresse (\`address\`) dessen, was sie liest.`,en:`${o.en}: The input "${l}" is bound through a path (\`path\`) \u2014 a binding carries the full address (\`address\`) of what it reads.`});r.type==="governedDocument"&&"resolver"in i&&t(`nodes.${r.id}.resolver`,{de:`${o.de}: \`resolver\` gibt es nicht mehr \u2014 der Generator ist der Eingang \`inputs.contractGenerator\` ({ kind, key }), seine Parameter stempelt die Plattform (\`generatorStamp\`), ein im Cockpit erg\xE4nzter Parameter ist sein Eingang \`{ kind: "cockpit" }\`.`,en:`${o.en}: \`resolver\` no longer exists \u2014 the generator is the input \`inputs.contractGenerator\` ({ kind, key }), the platform stamps its parameters (\`generatorStamp\`), a parameter completed in the cockpit is its input \`{ kind: "cockpit" }\`.`});let a=i.template;if(r.type==="governedDocument"&&a!==null&&typeof a=="object")for(let l of["key","cockpitFields"])l in a&&t(`nodes.${r.id}.template.${l}`,{de:`${o.de}: \`template.${l}\` gibt es nicht mehr \u2014 ${l==="key"?"die Vorlage ist der Eingang `inputs.documentTemplate`":'ein im Cockpit erg\xE4nzter Parameter ist sein Eingang `{ kind: "cockpit" }`'}.`,en:`${o.en}: \`template.${l}\` no longer exists \u2014 ${l==="key"?"the template is the input `inputs.documentTemplate`":'a parameter completed in the cockpit is its input `{ kind: "cockpit" }`'}.`});if(r.type==="setFlag")for(let l of["target","flagKey","value"])l in i&&t(`nodes.${r.id}.${l}`,{de:`${o.de}: \`${l}\` gibt es am setFlag-Knoten nicht mehr \u2014 Formular, Merkmal und Wert sind die Eing\xE4nge \`inputs.target\` (gebunden an die Adresse $node.<formular>.admission), \`inputs.flagKey\` und \`inputs.value\` (feste Werte).`,en:`${o.en}: \`${l}\` no longer exists on a setFlag node \u2014 form, flag and value are the inputs \`inputs.target\` (bound to the address $node.<form>.admission), \`inputs.flagKey\` and \`inputs.value\` (literals).`});for(let l of Object.keys(Py[r.type]??{}))l in i&&t(`nodes.${r.id}.${l}`,{de:`${o.de}: \`${l}\` gibt es als Knoteneigenschaft nicht mehr \u2014 es ist der Eingang \`inputs.${l}\` (ein fester Wert im Parameter-Bereich).`,en:`${o.en}: \`${l}\` no longer exists as a node property \u2014 it is the input \`inputs.${l}\` (a fixed value among the parameters).`});for(let l of Array.isArray(i.tasks)?i.tasks:[]){let d=l?.assign;d===null||typeof d!="object"||!("userId"in d)||t(`nodes.${r.id}.tasks.${String(l.key)}.assign.userId`,{de:`Aufgabe "${String(l.key)}" an ${o.de}: \`assign.userId\` gibt es nicht mehr \u2014 eine Aufgabe nennt ihr Team (\`assign.group\`), nie eine feste Person.`,en:`Task "${String(l.key)}" on ${o.en}: \`assign.userId\` no longer exists \u2014 a task names its team (\`assign.group\`), never a fixed person.`})}for(let l of Ny[r.type]??[])l in i&&t(`nodes.${r.id}.${l}`,{de:`${o.de}: \`${l}\` gibt es nicht mehr \u2014 dieser Knotentyp liest es nicht.`,en:`${o.en}: \`${l}\` no longer exists \u2014 this node type does not read it.`});for(let[l,d]of Object.entries(EO[r.type]??{}))l in i&&t(`nodes.${r.id}.${l}`,{de:`${o.de}: ${d.de}`,en:`${o.en}: ${d.en}`});i.adoptForm===!0&&t(`nodes.${r.id}.adoptForm`,{de:`${o.de}: \`adoptForm: true\` gibt es nicht mehr \u2014 \`adoptForm\` ist die Adresse des \xFCbernommenen Formulars ($node.<anlegender Formularknoten>.admission).`,en:`${o.en}: \`adoptForm: true\` no longer exists \u2014 \`adoptForm\` is the address of the adopted form ($node.<creating form node>.admission).`});for(let l of Array.isArray(i.tasks)?i.tasks:[]){let d=l?.result?.kind;typeof d=="string"&&tH.has(d)&&t(`nodes.${r.id}.tasks.${String(l.key)}.result`,{de:`Aufgabe "${String(l.key)}" an ${o.de}: das Ergebnis \u201E${d}" gibt es nicht mehr \u2014 die Gegenzeichnung ist der Knotentyp \u201EUnterschrift (intern)" (countersign).`,en:`Task "${String(l.key)}" on ${o.en}: the result "${d}" no longer exists \u2014 the countersignature is the node type "Signature (internal)" (countersign).`})}}return n}s(rH,"checkRetiredDataFields");function ta(e,n){return n?.wiring&&n.layout?{wiring:n.wiring,layout:n.layout}:null}s(ta,"resolveLayoutContext");function iH(e,n){let t=ta(e,n);if(!t)return e.nodes.some(o=>(He(o)?.progressEvents?.length??0)>0)?[{layer:"GRAPH",kind:"progressState",path:"graph.progressWiring",reason:{de:`Graph emittiert Progress-Events, aber (Layout, Wiring) konnte nicht aufgel\xF6st werden (Wiring ${n?.wiring?"vorhanden":"fehlt"}, Layout ${n?.layout?"vorhanden":"fehlt"}) \u2014 der Engine wirft beim Spiegeln zur Laufzeit. Der Workflow-Entwurf muss progressLayout und progressWiring tragen.`,en:`The graph emits progress events, but (layout, wiring) could not be resolved (wiring ${n?.wiring?"present":"missing"}, layout ${n?.layout?"present":"missing"}) \u2014 the engine throws at runtime when mirroring. The workflow draft must carry progressLayout and progressWiring.`},severity:"error"}]:[];let r=[];for(let i of e.nodes){let a=He(i)?.progressEvents;if(a)for(let l of a){let d=Ls(t.wiring,{id:i.id,type:i.type},l);if(!d){r.push({layer:"GRAPH",kind:"progressState",path:`node.${i.id}.progressEvents.${l}`,reason:{de:`${i.type} '${i.id}': Progress-Event '${l}' ist im Wiring (Layout '${t.layout.id}') keinem (Bus, State) zugeordnet \u2014 der Engine wirft beim Spiegeln`,en:`${i.type} '${i.id}': progress event '${l}' is not mapped to any (bus, state) in the wiring (layout '${t.layout.id}') \u2014 the engine throws when mirroring`},severity:"error"});continue}let c;try{c=_f(t.layout,d.bus)}catch{r.push({layer:"GRAPH",kind:"progressState",path:`node.${i.id}.progressEvents.${l}`,reason:{de:`${i.type} '${i.id}': Event '${l}' verweist auf unbekannten Bus '${d.bus}' im Layout '${t.layout.id}'`,en:`${i.type} '${i.id}': event '${l}' points to unknown bus '${d.bus}' in layout '${t.layout.id}'`},severity:"error"});continue}Al(c,d.state)||r.push({layer:"GRAPH",kind:"progressState",path:`node.${i.id}.progressEvents.${l}`,reason:{de:`${i.type} '${i.id}': Event '${l}' verweist auf State '${d.state}', der nicht im Bus '${d.bus}' deklariert ist`,en:`${i.type} '${i.id}': event '${l}' points to state '${d.state}', which is not declared in bus '${d.bus}'`},severity:"error"})}}return r}s(iH,"checkProgressEventMappings");function oH(e,n){let t=ta(e,n);if(!t)return[];let r=[];for(let i of t.layout.buses){if(!i.boards||i.boards.length===0)continue;let o=new Set(i.unboarded??[]),a=new Set;for(let l of i.boards)for(let d of l.columns)for(let c of d.states)a.add(c),Al(i,c)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.board.${l.id}.column.${d.id}.${c}`,reason:{de:`Board '${l.id}', Spalte '${d.id}' referenziert State '${c}', der nicht im Bus '${i.key}' deklariert ist`,en:`Board '${l.id}', column '${d.id}' references state '${c}', which is not declared in bus '${i.key}'`},severity:"error"});for(let l of i.states)a.has(l.id)||o.has(l.id)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.${l.id}`,reason:{de:`State '${l.id}' (${l.label.de}) erscheint in keiner Board-Spalte und nicht in 'unboarded' \u2014 nicht darstellbar`,en:`State '${l.id}' (${l.label.en}) appears in no board column and not in 'unboarded' \u2014 it cannot be displayed`},severity:"error"})}return r}s(oH,"checkProgressBoardCoverage");function sH(e,n){let t=ta(e,n);if(!t)return[];let r=[];for(let i of t.layout.buses)if(!(!i.boards||i.boards.length===0))for(let o of i.boards)for(let a of We){let l=new Map;for(let d of o.columns){if(!$i(d.label))continue;let c=d.label[a],u=c.trim().toLocaleLowerCase(a),p=l.get(u);if(p===void 0){l.set(u,d.id);continue}r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.board.${o.id}.column.${d.id}.label.${a}`,reason:{de:`Board '${o.id}' hat zwei Spalten mit dem Label '${c}' (${a}) ('${p}' und '${d.id}') \u2014 f\xFCr Lesende nicht unterscheidbar. F\xFChre die Spalten zusammen (states beider in EINE Spalte) oder vergib unterschiedliche Labels.`,en:`Board '${o.id}' has two columns with the label '${c}' (${a}) ('${p}' and '${d.id}') \u2014 readers cannot tell them apart. Merge the columns (put the states of both into ONE column) or give them different labels.`},severity:"error"})}}return r}s(sH,"checkProgressBoardDistinctLabels");function aH(e,n){let t=ta(e,n);if(!t)return[];let r=[];for(let i of t.layout.buses)for(let o of i.states){let a=Cf(i,o.id);o.terminal&&!a&&r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.${o.id}.terminalSemantics`,reason:{de:`Terminal-State '${o.id}' hat keine Terminal-Semantik im Bus '${i.key}' \u2014 der Engine wirft beim Versiegeln`,en:`Terminal state '${o.id}' has no terminal semantics in bus '${i.key}' \u2014 the engine throws when sealing`},severity:"error"}),!o.terminal&&a&&r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.${o.id}.terminalSemantics`,reason:{de:`State '${o.id}' ist nicht terminal, hat aber Terminal-Semantik im Bus '${i.key}' \u2014 Inkonsistenz`,en:`State '${o.id}' is not terminal but has terminal semantics in bus '${i.key}' \u2014 inconsistent`},severity:"error"})}return r}s(aH,"checkProgressTerminalSemantics");function lH(e,n){let t=ta(e,n);if(!t)return[];let r=[];for(let i of t.layout.buses){let o=new Set(i.holdsSeat??[]);for(let a of i.holdsSeat??[])Al(i,a)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.holdsSeat.${a}`,reason:{de:`holdsSeat referenziert '${a}', das kein State im Bus '${i.key}' ist`,en:`holdsSeat references '${a}', which is not a state in bus '${i.key}'`},severity:"error"});for(let a of i.commitsSeat??[])Al(i,a)?o.has(a)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.commitsSeat.${a}`,reason:{de:`commitsSeat '${a}' ist nicht in holdsSeat \u2014 ein fest belegter Platz muss auch belegt sein`,en:`commitsSeat '${a}' is not in holdsSeat \u2014 a firmly committed seat must also be held`},severity:"error"}):r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.commitsSeat.${a}`,reason:{de:`commitsSeat referenziert '${a}', das kein State im Bus '${i.key}' ist`,en:`commitsSeat references '${a}', which is not a state in bus '${i.key}'`},severity:"error"});for(let[a,l]of Object.entries(i.terminalSemantics??{}))l.outcome==="approved"&&(o.has(a)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.holdsSeat`,reason:{de:`Endzustand '${a}' schlie\xDFt den Prozess positiv ab (outcome 'approved'), steht aber nicht in holdsSeat \u2014 damit z\xE4hlt er als Absage und f\xE4llt aus dem Fortschrittsbalken. Nimm '${a}' in holdsSeat (und in commitsSeat, wenn der Platz damit wirklich belegt ist) auf.`,en:`Final state '${a}' ends the process positively (outcome 'approved'), but is not in holdsSeat \u2014 so it counts as a rejection and drops out of the progress bar. Add '${a}' to holdsSeat (and to commitsSeat, if the seat is really taken by it).`},severity:"error"}))}return r}s(lH,"checkProgressSeatStates");var kp={de:"Abhilfe: nach dem Formularknoten einen review-Knoten einf\xFCgen und dessen 'reviewing' auf diesen Zustand mappen",en:"Remedy: insert a review node after the form node and map its 'reviewing' to this state"};function dH(e){return e==="both"?{de:`${kp.de} \u2014 die Spalte ist auch der Schritt, den die Familie sieht; den Zustand in die Spalte des Nachfolgers zu legen, n\xE4hme ihr diesen Schritt.`,en:`${kp.en} \u2014 the column is also the step the family sees; moving the state into the successor's column would take that step away from them.`}:{de:`${kp.de}, oder den Zustand in die Spalte des Nachfolgers legen.`,en:`${kp.en}, or move the state into the successor's column.`}}s(dH,"passThroughRemedy");function cH(e,n){let t=ta(e,n);if(!t)return[];let{layout:r,wiring:i}=t;if(!r.buses.some(v=>v.key==="process"))return[];let o=zO(r);if(!o)return[];let a=new Map(e.nodes.map(v=>[v.id,v])),l=s(v=>He(v).progressEvents??[],"eventsOf"),d=s(v=>Object.values(v.next??{}).map(E=>E.to),"routesOf"),c=s((v,E)=>{let A=a.get(v);if(!A||E.has(v))return null;if(l(A).length>0)return[A];if(S_[A.type]!==!1)return null;let I=d(A);if(I.length===0)return null;let _=[];for(let T of I){let b=c(T,new Set([...E,v]));if(!b)return null;_.push(...b)}return _},"firstProgressNodes"),u=s((v,E)=>{let A=[];for(let I of l(v)){let _=Ls(i,v,I);if(!_||_.bus!==E.bus||_.state===E.state)return null;A.push(_.state)}return[...new Set(A)].join("' / '")},"overwrites"),p=s((v,E)=>{let A=d(v);if(A.length===0)return null;let I=[];for(let _ of A){let T=c(_,new Set([v.id]));if(!T)return null;for(let b of T){let R=u(b,E);if(R===null)return null;I.push({de:`'${b.id}' (${b.type}) mit '${R}'`,en:`'${b.id}' (${b.type}) with '${R}'`})}}return[...new Map(I.map(_=>[_.de,_])).values()]},"submitOverwrittenBy"),m=new Map;for(let v of e.nodes)for(let E of l(v)){let A=Ls(i,v,E);if(!A||A.bus!=="process")continue;let I=v.type==="form"&&E===Xu?p(v,A):null,_=I?{de:`'${v.id}'.${E} erreicht ihn, und ${I.map(T=>T.de).join(", ")} \xFCberschreibt ihn in derselben Transaktion`,en:`'${v.id}'.${E} reaches it, and ${I.map(T=>T.en).join(", ")} overwrites it in the same transaction`}:null;m.set(A.state,[...m.get(A.state)??[],_])}let y=_f(r,"process"),k=new Map;for(let[v,E]of m){if(!E.every(I=>I!==null))continue;let A=[...new Map(E.map(I=>[I.de,I])).values()];k.set(v,{de:A.map(I=>I.de).join("; "),en:A.map(I=>I.en).join("; ")})}let g=[];for(let v of o.columns){if(v.states.length===0||!v.states.every(I=>k.has(I)))continue;let E=v.states.map(I=>{let _=y.holdsSeat?.includes(I)===!0,T=k.get(I);return{de:`Zustand '${I}'${_?" (steht in holdsSeat, belegt aber nie einen Platz)":""}: ${T.de}`,en:`State '${I}'${_?" (is in holdsSeat, but never takes a seat)":""}: ${T.en}`}}),A=dH(o.audience);g.push({layer:"GRAPH",kind:"progressState",path:`progressLayout.process.boards.${o.id}.columns.${v.id}`,reason:{de:`[progress/passThroughState] Spalte \u201E${v.label.de}" ('${v.id}', Board '${o.id}') bleibt immer leer \u2014 ${E.map(I=>I.de).join("; ")}. ${A.de}`,en:`[progress/passThroughState] Column "${v.label.en}" ('${v.id}', board '${o.id}') always stays empty \u2014 ${E.map(I=>I.en).join("; ")}. ${A.en}`},severity:"warning"})}return g}s(cH,"checkProgressPassThroughColumns");function uH(e){let n=["workItems","workitems","work_items","taskTemplates"],t=[];for(let r of e.nodes){let i=r;for(let o of n){let a=i[o];a!=null&&t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.${o}`,reason:{de:`[workItems/misnamedTasksKey] Knoten "${r.id}" deklariert "${o}" \u2014 komponierte Aufgaben werden ausschlie\xDFlich unter "tasks" gelesen. So wie es dasteht, w\xFCrde die Aufgabenkette stillschweigend nie entstehen. Benenne den Schl\xFCssel in "tasks" um.`,en:`[workItems/misnamedTasksKey] Node "${r.id}" declares "${o}" \u2014 composed tasks are read only from "tasks". As it stands, the task chain would silently never be created. Rename the key to "tasks".`},severity:"error"})}}return t}s(uH,"checkMisnamedTasksKey");function fH(e){let n=[];for(let t of e.nodes){let r=t,i=Array.isArray(r.tasks)?r.tasks:[],o=new Set;for(let c of i){let u=typeof c.key=="string"?c.key:void 0;u!==void 0&&(o.has(u)&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}`,reason:{de:`[workItems/duplicateTemplateKey] Doppelter Template-Key "${u}" auf Knoten "${r.id}".`,en:`[workItems/duplicateTemplateKey] Duplicate template key "${u}" on node "${r.id}".`},severity:"error"}),o.add(u))}let a=new Set;for(let c of Array.isArray(r.artifacts)?r.artifacts:[])typeof c.key=="string"&&a.add(`${c.key}Uploaded`);let l=He(t),d=new Map((typeof l.workItemTemplates=="function"?l.workItemTemplates(t):[]).map(c=>[c.key,c]));for(let c of i){let u=typeof c.key=="string"?c.key:"?",p=typeof c.kind=="string"?c.kind:void 0;if(p===void 0||!Nl.has(p)){n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.kind`,reason:{de:`[workItems/invalidKind] Task "${u}" auf Knoten "${r.id}" hat Art ${JSON.stringify(c.kind)}; komponierbar sind: ${[...Nl].join(", ")}.`,en:`[workItems/invalidKind] Task "${u}" on node "${r.id}" has kind ${JSON.stringify(c.kind)}; composable kinds are: ${[...Nl].join(", ")}.`},severity:"error"});continue}p==="task"&&c.gatesNode!==void 0&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.gatesNode`,reason:{de:`[workItems/gatesNodeOnTask] 'gatesNode' ist nur f\xFCr die Art 'approval' zul\xE4ssig \u2014 eine Task gated ihren Knoten nie direkt. Um eine gatende Freigabe zur\xFCckzuhalten, 'blocks' verwenden (Task "${u}" auf Knoten "${r.id}").`,en:`[workItems/gatesNodeOnTask] 'gatesNode' is only allowed for the kind 'approval' \u2014 a task never gates its node directly. To hold back a gating approval, use 'blocks' (task "${u}" on node "${r.id}").`},severity:"error"});let m=c.blocks,y=m===void 0?void 0:KN(e,r.id,m.node);if(m!==void 0&&y===null)n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.node`,reason:{de:`[workItems/blocksUnknownNode] 'blocks.node' auf Task "${u}" (Knoten "${r.id}") nennt ${JSON.stringify(m.node)} \u2014 diesen Knoten gibt es im Workflow nicht.`,en:`[workItems/blocksUnknownNode] 'blocks.node' on task "${u}" (node "${r.id}") names ${JSON.stringify(m.node)} \u2014 there is no such node in the workflow.`},severity:"error"});else if(m!==void 0&&y!==void 0&&y!==null){let g=y.node.id===r.id,v=y.node.id,E=g?o:y.composedKeys,A=g?d:y.intrinsicByKey,I=y.node.assign??{};p==="approval"&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks`,reason:{de:`[workItems/blocksOnApproval] 'blocks' ist auf der Art 'approval' verboten \u2014 nur Task-Zeilen d\xFCrfen einen Geschwister-Spawn zur\xFCckhalten (Approval "${u}" auf Knoten "${r.id}").`,en:`[workItems/blocksOnApproval] 'blocks' is forbidden on the kind 'approval' \u2014 only task rows may hold back a sibling spawn (approval "${u}" on node "${r.id}").`},severity:"error"});let _=m.templateKey,T=[...new Set([...E,...A.keys()])].filter(R=>!g||R!==u).join(", "),b={de:T||"keine",en:T||"none"};if(typeof _!="string"||g&&_===u||!E.has(_)&&!A.has(_))n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.templateKey`,reason:{de:`[workItems/blocksUnknownTarget] 'blocks' muss ein Template auf dem Zielknoten benennen \u2014 komponiert ODER intrinsisch (nie sich selbst, nie ohne 'templateKey': die zielfreie Form geh\xF6rt der Maschine, nicht dem Autor). Ziel ${JSON.stringify(_)} auf Knoten "${v}"; zul\xE4ssige Ziele: ${b.de}.`,en:`[workItems/blocksUnknownTarget] 'blocks' must name a template on the target node \u2014 composed OR intrinsic (never itself, never without 'templateKey': the target-less form belongs to the engine, not the author). Target ${JSON.stringify(_)} on node "${v}"; allowed targets: ${b.en}.`},severity:"error"});else if(y.refuse(_)!==null)n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.templateKey`,reason:y.refuse(_),severity:"error"});else{let R=A.get(_);m.except!==void 0&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.except`,reason:{de:`[workItems/blocksExceptRetired] 'blocks.except' auf Task "${u}" (Knoten "${r.id}") gibt es nicht mehr: eine blockierende Aufgabe sperrt die ganze Aktionsgruppe ihres Ziels (bei einer Entscheidung Freigeben, Warteliste, Ablehnen und das Nachr\xFCcken). 'except' entfernen.`,en:`[workItems/blocksExceptRetired] 'blocks.except' on task "${u}" (node "${r.id}") no longer exists: a blocking task locks the whole action group of its target (for a decision: approve, waitlist, reject and promote). Remove 'except'.`},severity:"error"}),R!==void 0&&R.recipient!=="external"&&R.verdictResolved!==!0&&typeof I[_]!="string"&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.templateKey`,reason:{de:`[workItems/blocksUnwiredTarget] Task "${u}" auf Knoten "${r.id}" h\xE4lt "${_}" (Knoten "${v}") zur\xFCck, aber der Knoten weist "${_}" keiner Gruppe zu \u2014 ohne 'assign.${_}' entsteht diese Zeile nie: kein Team bekommt die zur\xFCckgehaltene Arbeit, niemand au\xDFer der verantwortlichen Person kann sie tun. Entweder 'assign.${_}' erg\xE4nzen oder das 'blocks' entfernen.`,en:`[workItems/blocksUnwiredTarget] Task "${u}" on node "${r.id}" holds back "${_}" (node "${v}"), but the node assigns "${_}" to no group \u2014 without 'assign.${_}' this row is never created: no team receives the held-back work, and nobody except the responsible person can do it. Either add 'assign.${_}' or remove the 'blocks'.`},severity:"error"})}}{let g=c.completableIf;if(typeof g=="string"&&g.trim().length>0){let v=g.trim().replace(/^!/,"").trim();a.has(v)||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.completableIf`,reason:{de:`[workItems/unknownExport] completableIf "${g}" verweist auf unbekannten Node-Export "${v}"; bekannt: ${[...a].join(", ")||"keine"}.`,en:`[workItems/unknownExport] completableIf "${g}" refers to unknown node export "${v}"; known: ${[...a].join(", ")||"none"}.`},severity:"error"})}}let k=c.params;if(k?.commentRequired!==void 0&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.params.commentRequired`,reason:{de:"[workItems/removedParam] 'params.commentRequired' wurde entfernt \u2014 Kommentar-Pflichten werden am Decision-Node ('commentRequired') autorisiert.",en:"[workItems/removedParam] 'params.commentRequired' was removed \u2014 comment requirements are authored on the decision node ('commentRequired')."},severity:"error"}),p!=="approval"){let g=[];k?.onReject!==void 0&&g.push("params.onReject"),k?.revisionGroup!==void 0&&g.push("params.revisionGroup");for(let v of g)n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.${v}`,reason:{de:`[workItems/approvalOnlyField] '${v}' gilt nur f\xFCr die Art 'approval' (Task "${u}" ist '${p}').`,en:`[workItems/approvalOnlyField] '${v}' only applies to the kind 'approval' (task "${u}" is '${p}').`},severity:"error"});continue}k?.onReject!==void 0&&k.onReject!=="spawnRevision"&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.params.onReject`,reason:{de:`[workItems/invalidOnReject] Erwartet 'spawnRevision', erhalten ${JSON.stringify(k.onReject)}.`,en:`[workItems/invalidOnReject] Expected 'spawnRevision', got ${JSON.stringify(k.onReject)}.`},severity:"error"}),k?.onReject==="spawnRevision"&&(typeof k.revisionGroup!="string"||k.revisionGroup.length===0)&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.params.revisionGroup`,reason:{de:`[workItems/spawnRevisionNoTarget] Approval "${u}" mit 'params.onReject: spawnRevision' ohne 'params.revisionGroup' \u2014 die \xDCberarbeitung h\xE4tte keine Ziel-Gruppe.`,en:`[workItems/spawnRevisionNoTarget] Approval "${u}" with 'params.onReject: spawnRevision' but no 'params.revisionGroup' \u2014 the revision would have no target group.`},severity:"error"})}}return n.push(...jN(e)),n}s(fH,"checkWorkItemTemplates");var pH=new Set(["complete","approve","reject"]),S_={form:!0,decision:!0,review:!0,waitlist:!0,completenessCheck:!0,collectPayment:!0,eventTrigger:!0,join:!1,roleAssign:!1,setFlag:!1,if:!1,end:!1,countersign:!0,engagePush:!1,governedDocument:!0};function mH(e){let n=[];for(let t of e.nodes){let r=t,i=He(t),o=Array.isArray(r.tasks)?r.tasks.length:0,a=i.workItemTemplates?.(t)??[];if(o+a.length>0){let v=S_[r.type];v===void 0?n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks`,reason:{de:`[workItems/unknownParkSemantics] Knotentyp "${r.type}" hat keine bekannte Park-Semantik \u2014 NODE_TYPE_PARKS in validators.ts erg\xE4nzen.`,en:`[workItems/unknownParkSemantics] Node type "${r.type}" has no known parking semantics \u2014 add it to NODE_TYPE_PARKS in validators.ts.`},severity:"error"}):v||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks`,reason:{de:`[workItems/templatesOnNonParkingNode] Knoten "${r.id}" (Typ "${r.type}") parkt nie \u2014 seine Work-Item-Templates w\xFCrden im selben Dispatch gespawnt und storniert (totes Muster).`,en:`[workItems/templatesOnNonParkingNode] Node "${r.id}" (type "${r.type}") never parks \u2014 its work-item templates would be spawned and cancelled in the same dispatch (dead pattern).`},severity:"error"})}let l=i.actions?.(t)??[];if(l.length===0&&a.length===0)continue;let d=new Map(l.map(v=>[v.id,v]));for(let v of l)pH.has(v.id)&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actions.${v.id}`,reason:{de:`[capability/reservedActionId] Knotentyp "${r.type}" deklariert die Action "${v.id}" \u2014 reserviert f\xFCr den generischen Complete-/Verdict-Pfad (complete, approve, reject); die Spec muss eine andere Action-Id w\xE4hlen.`,en:`[capability/reservedActionId] Node type "${r.type}" declares the action "${v.id}" \u2014 reserved for the generic complete/verdict path (complete, approve, reject); the spec must choose a different action id.`},severity:"error"});let c=new Set(i.states??[lP]);for(let v of l)if(v.availableIn!==void 0)for(let E of v.availableIn)c.has(E)||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actions.${v.id}.availableIn`,reason:{de:`[capability/unknownActionState] Action "${v.id}" auf Knotentyp "${r.type}" ist f\xFCr Zustand "${E}" deklariert \u2014 der Typ kennt nur: ${[...c].join(", ")}.`,en:`[capability/unknownActionState] Action "${v.id}" on node type "${r.type}" is declared for state "${E}" \u2014 the type only knows: ${[...c].join(", ")}.`},severity:"error"});let u=Hy(t),p=new Set(u?u.map(v=>v.id):[Bs]);for(let v of l){if(v.external===void 0)continue;let E=aP(v.external.event),A={de:"hat keine Beschriftung (der Empf\xE4nger bekommt einen leeren Button)",en:"has no label (the recipient would get an empty button)"},I=E?v.kind==="advance"?{de:`ist als "advance" deklariert, l\xF6st den Knoten aber nicht auf (Ereignis "${v.external.event}") \u2014 solche Aktionen sind "internal"`,en:`is declared as "advance", but does not resolve the node (event "${v.external.event}") \u2014 such actions are "internal"`}:v.outcome!==void 0?{de:`nennt das Outcome "${v.outcome}", l\xF6st den Knoten aber nicht auf (Ereignis "${v.external.event}") \u2014 ein Outcome w\xFCrde eine zweite, stille Routing-Vokabel behaupten`,en:`names the outcome "${v.outcome}", but does not resolve the node (event "${v.external.event}") \u2014 an outcome would claim a second, silent routing vocabulary`}:v.label===void 0?A:null:v.kind!=="advance"?{de:`ist als "${v.kind}" deklariert (externe Aktionen l\xF6sen den Knoten auf und m\xFCssen "advance" sein)`,en:`is declared as "${v.kind}" (external actions resolve the node and must be "advance")`}:v.outcome===void 0?{de:"nennt kein Outcome",en:"names no outcome"}:p.has(v.outcome)?v.label===void 0?A:null:{de:`verweist auf das unbekannte Outcome "${v.outcome}" (deklariert: ${[...p].join(", ")||"keine"})`,en:`refers to the unknown outcome "${v.outcome}" (declared: ${[...p].join(", ")||"none"})`};I!==null&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actions.${v.id}.external`,reason:{de:`[capability/externalActionNeedsOutcome] Externe Aktion "${v.id}" auf Knotentyp "${r.type}" ${I.de}.`,en:`[capability/externalActionNeedsOutcome] External action "${v.id}" on node type "${r.type}" ${I.en}.`},severity:"error"})}for(let v of a){let E=v.unlocks;if(E.length===0&&v.verdictResolved!==!0){n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.workItemTemplates.${v.key}.unlocks`,reason:{de:`[capability/emptyUnlocks] Intrinsisches Template "${v.key}" auf Knoten "${r.id}" schaltet keine Action frei (B5).`,en:`[capability/emptyUnlocks] Intrinsic template "${v.key}" on node "${r.id}" unlocks no action (B5).`},severity:"error"});continue}for(let A of E)d.get(A)===void 0&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.workItemTemplates.${v.key}.unlocks`,reason:{de:`[capability/danglingUnlock] Template "${v.key}" auf Knoten "${r.id}" schaltet unbekannte Action "${A}" frei; deklariert: ${[...d.keys()].join(", ")||"keine"}.`,en:`[capability/danglingUnlock] Template "${v.key}" on node "${r.id}" unlocks the unknown action "${A}"; declared: ${[...d.keys()].join(", ")||"none"}.`},severity:"error"})}let m=new Set(a.map(v=>v.key));for(let v of Object.keys(r.assign??{}))m.has(v)||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.assign.${v}`,reason:{de:`[capability/unknownAssignKey] assign-Key "${v}" auf Knoten "${r.id}" ist kein intrinsisches Template dieses Knotentyps; bekannt: ${[...m].join(", ")||"keine"}.`,en:`[capability/unknownAssignKey] assign key "${v}" on node "${r.id}" is not an intrinsic template of this node type; known: ${[...m].join(", ")||"none"}.`},severity:"error"});let y=l.filter(v=>v.teamAssignable===!0).map(v=>v.id);for(let v of Object.keys(r.actionTeams??{}))y.includes(v)||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actionTeams.${v}`,reason:{de:`[capability/unknownActionTeam] Knoten "${r.id}" nennt ein Team f\xFCr "${v}", aber diese Aktion l\xE4sst sich hier keinem Team geben; m\xF6glich: ${y.join(", ")||"keine"}.`,en:`[capability/unknownActionTeam] Node "${r.id}" names a team for "${v}", but this action cannot be given to a team here; possible: ${y.join(", ")||"none"}.`},severity:"error"});let k=new Set;for(let v of a)if(v.recipient==="external"||typeof(r.assign??{})[v.key]=="string")for(let A of v.unlocks)k.add(A);let g=i.strictActionCoverage===!0;for(let v of l){if(k.has(v.id)||v.superUserOnly===!0)continue;let E=a.find(I=>I.unlocks.includes(v.id)),A=E!==void 0?{de:` Fehlt die Zuweisung assign.${E.key}?`,en:` Is the assignment assign.${E.key} missing?`}:{de:"",en:""};n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actions.${v.id}`,reason:{de:`[capability/superUserOnly] Action "${v.id}" auf Knoten "${r.id}" ist von keinem verdrahteten Work-Item freigeschaltet \u2014 nur die verantwortliche Person (Super-User) kann sie ausf\xFChren.${A.de}`,en:`[capability/superUserOnly] Action "${v.id}" on node "${r.id}" is unlocked by no wired work item \u2014 only the responsible person (super user) can perform it.${A.en}`},severity:g?"error":"warning"})}}return n}s(mH,"checkNodeCapabilityWiring");function hH(e){let n=new Set(QI()),t=[];for(let r of e.nodes)n.has(r.type)||t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.type`,reason:{de:`[graph/unknownNodeType] Knoten "${r.id}" hat den unbekannten Typ "${String(r.type)}". Registrierte Typen: ${[...n].join(", ")}.`,en:`[graph/unknownNodeType] Node "${r.id}" has the unknown type "${String(r.type)}". Registered types: ${[...n].join(", ")}.`},severity:"error"});return t}s(hH,"checkKnownNodeTypes");function gH(e,n){let t=[],r=s((a,l)=>{t.push({layer:"GRAPH",kind:"nodeRule",path:a,reason:l,severity:"error"})},"push"),i=tI(e),o=s(a=>typeof a=="object"&&a!==null&&Object.values(a).some(l=>typeof l=="string"&&l.trim().length>0),"hasText");for(let a of e.nodes){let l=a,d=Array.isArray(l.optionalActions)?l.optionalActions:[];if(t.push(...OH(l,d)),d.length===0)continue;let c=He(a),u=new Set(c.optionalActionKinds??[]),p=Array.isArray(l.tasks)?l.tasks:[],m=new Map;for(let g of p)typeof g.key=="string"&&m.set(g.key,g);let y=new Set,k=new Map;for(let g of d){let v=g.key,E=typeof v=="string"&&v.trim().length>0?v:void 0,A=E??"?",I=`nodes.${l.id}.optionalActions.${A}`,_=typeof g.action=="string"?g.action:void 0;if(g.when!==void 0){let T=s(b=>r(`${I}.when`,{de:`[optionalAction/when] Optionale Aktion "${A}" auf Knoten "${l.id}": ${b.de}`,en:`[optionalAction/when] Optional action "${A}" on node "${l.id}": ${b.en}`}),"conditionFinding");if(typeof g.when!="string"||g.when.trim()==="")T({de:"Die Bedingung ist leer \u2014 ohne Bedingung das Feld weglassen.",en:"The condition is empty \u2014 without a condition, omit the field."});else for(let b of tp(g.when,i,n))T(b)}if((_===void 0||!u.has(_))&&r(`${I}.action`,{de:`[optionalAction/kindNotDeclared] Optionale Aktion "${A}" auf Knoten "${l.id}" hat die Art ${JSON.stringify(g.action)} \u2014 `+(u.size===0?`Knotentyp "${l.type}" deklariert keine Familien (spec.optionalActionKinds fehlt).`:`Knotentyp "${l.type}" deklariert nur: ${[...u].join(", ")}.`),en:`[optionalAction/kindNotDeclared] Optional action "${A}" on node "${l.id}" has the kind ${JSON.stringify(g.action)} \u2014 `+(u.size===0?`node type "${l.type}" declares no families (spec.optionalActionKinds is missing).`:`node type "${l.type}" only declares: ${[...u].join(", ")}.`)}),E===void 0?r(`${I}.key`,{de:`[optionalAction/missingKey] Optionale Aktion auf Knoten "${l.id}" ohne (oder mit leerem) 'key' \u2014 Trigger-Action und Template-Keys w\xE4ren namenlos ('optionalAction::\u2026').`,en:`[optionalAction/missingKey] Optional action on node "${l.id}" without (or with an empty) 'key' \u2014 the trigger action and template keys would be nameless ('optionalAction::\u2026').`}):(y.has(E)&&r(`${I}.key`,{de:`[optionalAction/duplicateKey] Doppelter Aktions-Key "${E}" auf Knoten "${l.id}" \u2014 die projizierten Trigger-Actions w\xFCrden kollidieren.`,en:`[optionalAction/duplicateKey] Duplicate action key "${E}" on node "${l.id}" \u2014 the projected trigger actions would collide.`}),y.add(E)),o(g.label)||r(`${I}.label`,{de:`[optionalAction/missingLabel] Optionale Aktion "${A}" auf Knoten "${l.id}" ohne Label \u2014 der Trigger-Button w\xE4re unbeschriftet.`,en:`[optionalAction/missingLabel] Optional action "${A}" on node "${l.id}" without a label \u2014 the trigger button would be unlabeled.`}),_==="spawnTasks"){g.except!==void 0&&r(`${I}.except`,{de:`[optionalAction/exceptRetired] Optionale Aktion "${A}" auf Knoten "${l.id}" tr\xE4gt 'except' \u2014 das gibt es nicht mehr: solange die Aufgaben offen sind, ist die ganze Aktionsgruppe des Knotens gesperrt. 'except' entfernen.`,en:`[optionalAction/exceptRetired] Optional action "${A}" on node "${l.id}" carries 'except' \u2014 that no longer exists: while the tasks are open, the node's whole action group is locked. Remove 'except'.`});let T=Array.isArray(g.tasks)?g.tasks:void 0;if(T===void 0||T.length===0)r(`${I}.tasks`,{de:`[optionalAction/tasksEmpty] Optionale Aktion "${A}" auf Knoten "${l.id}" referenziert keine Aufgaben-Templates \u2014 der Trigger w\xFCrde nichts erzeugen.`,en:`[optionalAction/tasksEmpty] Optional action "${A}" on node "${l.id}" references no task templates \u2014 the trigger would create nothing.`});else{let b=new Set,R=new Set(T.filter(q=>typeof q=="string"));for(let q of T){let P=typeof q=="string"?q:void 0;if(P===void 0||P.length===0){r(`${I}.tasks`,{de:`[optionalAction/unknownTaskRef] Optionale Aktion "${A}" auf Knoten "${l.id}" enth\xE4lt eine leere/ung\xFCltige Template-Referenz.`,en:`[optionalAction/unknownTaskRef] Optional action "${A}" on node "${l.id}" contains an empty or invalid template reference.`});continue}if(b.has(P)){r(`${I}.tasks.${P}`,{de:`[optionalAction/duplicateTaskRef] Template "${P}" ist in der Aktion "${A}" auf Knoten "${l.id}" doppelt referenziert.`,en:`[optionalAction/duplicateTaskRef] Template "${P}" is referenced twice in the action "${A}" on node "${l.id}".`});continue}b.add(P);let J=m.get(P);if(J===void 0){r(`${I}.tasks.${P}`,{de:`[optionalAction/unknownTaskRef] Optionale Aktion "${A}" auf Knoten "${l.id}" referenziert das Template "${P}", das node.tasks nicht deklariert. Vorhanden: ${[...m.keys()].join(", ")||"keine"}.`,en:`[optionalAction/unknownTaskRef] Optional action "${A}" on node "${l.id}" references the template "${P}", which node.tasks does not declare. Present: ${[...m.keys()].join(", ")||"none"}.`});continue}let Y=k.get(P);Y!==void 0&&Y!==A?r(`${I}.tasks.${P}`,{de:`[optionalAction/taskDoublyBound] Template "${P}" auf Knoten "${l.id}" ist bereits von der Aktion "${Y}" referenziert \u2014 ein Template geh\xF6rt zu h\xF6chstens einer optionalen Aktion.`,en:`[optionalAction/taskDoublyBound] Template "${P}" on node "${l.id}" is already referenced by the action "${Y}" \u2014 a template belongs to at most one optional action.`}):k.set(P,A);let fe=J.blocks?.templateKey;typeof fe=="string"&&!R.has(fe)&&r(`${I}.tasks.${P}`,{de:`[optionalAction/taskRefBlocks] Template "${P}" auf Knoten "${l.id}" tr\xE4gt 'blocks' auf "${fe}", das nicht zur selben Aktion "${A}" geh\xF6rt \u2014 eine Referenz darf nur eine Referenz DERSELBEN Aktion zur\xFCckhalten (Checklisten-Reihenfolge), nie ein Template au\xDFerhalb.`,en:`[optionalAction/taskRefBlocks] Template "${P}" on node "${l.id}" carries 'blocks' on "${fe}", which does not belong to the same action "${A}" \u2014 a reference may only hold back a reference of the SAME action (checklist order), never a template outside it.`});for(let Q of p){let re=typeof Q.key=="string"?Q.key:void 0;Q.blocks?.templateKey===P&&(re!==void 0&&R.has(re)||r(`${I}.tasks.${P}`,{de:`[optionalAction/taskRefBlocks] Template "${P}" auf Knoten "${l.id}" ist Ziel eines 'blocks' von ${re!==void 0?`"${re}"`:"einem Template"} au\xDFerhalb der Aktion "${A}" \u2014 ein Template au\xDFerhalb darf eine Referenz nie zur\xFCckhalten (ihr Spawn geh\xF6rt dem Trigger, nicht onEnter).`,en:`[optionalAction/taskRefBlocks] Template "${P}" on node "${l.id}" is the target of a 'blocks' from ${re!==void 0?`"${re}"`:"a template"} outside the action "${A}" \u2014 a template outside may never hold back a reference (its spawn belongs to the trigger, not to onEnter).`}))}}}}}}return t}s(gH,"checkOptionalActions");function yH(e){return typeof e=="number"?"number":typeof e=="boolean"?"boolean":"string"}s(yH,"literalValueType");function wH(e,n){let t=[],r=n?.notificationTemplates;for(let i of e.nodes){let o=i,a=RP(i,He(i)),l=o.notifications??{};if(a.length===0&&Object.keys(l).length===0)continue;let d=new Map(a.map(c=>[c.id,c]));for(let c of Object.keys(l))d.has(c)||t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${o.id}.notifications.${c}`,reason:{de:`[notification/unknownEvent] Knoten "${o.id}" bindet einen Brief an das Ereignis "${c}", das der Knotentyp "${o.type}" nicht kennt. Angeboten werden: ${a.map(u=>u.id).join(", ")||"(keine)"}.`,en:`[notification/unknownEvent] Node "${o.id}" binds a letter to the event "${c}", which the node type "${o.type}" does not know. Offered: ${a.map(u=>u.id).join(", ")||"(none)"}.`},severity:"error"});for(let c of a){let u=l[c.id];if(c.required===!0&&(u===void 0||u.disabled===!0)){t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${o.id}.notifications.${c.id}`,reason:{de:`[notification/missingBinding] Knoten "${o.id}" muss beim Ereignis "${c.label.de}" (${c.id}) einen Brief verschicken \u2014 es ist ${u===void 0?"keiner gebunden":"einer gebunden, aber abgeschaltet"}.`,en:`[notification/missingBinding] Node "${o.id}" must send a letter on the event "${c.label.en}" (${c.id}) \u2014 ${u===void 0?"none is bound":"one is bound, but switched off"}.`},severity:"error"});continue}if(u===void 0||u.disabled===!0)continue;let p=`nodes.${o.id}.notifications.${c.id}`;if(c.audience!=="external"){t.push({layer:"GRAPH",kind:"nodeRule",path:p,reason:{de:`[notification/internalAudienceUnsupported] Knoten "${o.id}": das Ereignis "${c.id}" richtet sich an die Schule, und Briefe an die Schule k\xF6nnen noch nicht zugestellt werden \u2014 der gebundene Brief "${u.templateId}" w\xFCrde den Vorgang beim Versand abbrechen.`,en:`[notification/internalAudienceUnsupported] Node "${o.id}": the event "${c.id}" is addressed to the school, and letters to the school cannot be delivered yet \u2014 the bound letter "${u.templateId}" would abort the process when it is sent.`},severity:"error"});continue}if(r===void 0)continue;let m=r.get(u.templateId);if(m===void 0){t.push({layer:"GRAPH",kind:"nodeRule",path:p,reason:{de:`[notification/unknownTemplate] Knoten "${o.id}": der Brief "${u.templateId}" ist nicht im Katalog. Bekannt sind: ${[...r.keys()].sort().join(", ")||"(keine)"}.`,en:`[notification/unknownTemplate] Node "${o.id}": the letter "${u.templateId}" is not in the catalog. Known: ${[...r.keys()].sort().join(", ")||"(none)"}.`},severity:"error"});continue}m.audience!==void 0&&m.audience!==c.audience&&t.push({layer:"GRAPH",kind:"nodeRule",path:p,reason:{de:`[notification/audienceMismatch] Der Brief "${m.id}" ist f\xFCr ${m.audience==="internal"?"die Schule":"die Familie"} geschrieben, das Ereignis "${c.id}" richtet sich aber an die Familie.`,en:`[notification/audienceMismatch] The letter "${m.id}" is written for ${m.audience==="internal"?"the school":"the family"}, but the event "${c.id}" is addressed to the family.`},severity:"warning"});let y=SP(c),k=new Set(m.params.map(g=>g.key));for(let g of Object.keys(u.args??{}))k.has(g)||t.push({layer:"GRAPH",kind:"nodeRule",path:`${p}.args.${g}`,reason:{de:`[notification/unknownArg] Der Brief "${m.id}" hat kein Argument "${g}" \u2014 erwartet werden: ${m.params.map(v=>v.key).join(", ")||"(keine)"}.`,en:`[notification/unknownArg] The letter "${m.id}" has no argument "${g}" \u2014 expected: ${m.params.map(v=>v.key).join(", ")||"(none)"}.`},severity:"error"});for(let g of m.params){let v=u.args?.[g.key],E=`${p}.args.${g.key}`;if(v!==void 0&&"literal"in v){let I=yH(v.literal);g.type!==void 0&&!lw(I,g.type)&&t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/argTypeMismatch] "${g.key}" erwartet ${Ol(g.type).de}, festgelegt ist aber ${JSON.stringify(v.literal)} (${I}).`,en:`[notification/argTypeMismatch] "${g.key}" expects ${Ol(g.type).en}, but ${JSON.stringify(v.literal)} (${I}) is set.`},severity:"error"});continue}if(v!==void 0){t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/unsupportedArg] "${g.key}" ist an ${JSON.stringify(v)} gebunden \u2014 ein Brief-Argument kann nur ein Festwert ({ literal }) sein oder automatisch aus ${x_(y,"de")} kommen.`,en:`[notification/unsupportedArg] "${g.key}" is bound to ${JSON.stringify(v)} \u2014 a letter argument can only be a fixed value ({ literal }) or come automatically from ${x_(y,"en")}.`},severity:"error"});continue}let A=AP(g,y.get(g.key)??[]);if(!(A.status==="resolved"||A.status==="unused")){if(A.status==="sometimes"){t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/unresolvedArg] Der Brief "${m.id}" braucht "${g.key}" immer, ${A.source.source} liefert es aber nur manchmal. In notifications.${c.id}.args.${g.key} einen Festwert benennen \u2014 oder einen Brief w\xE4hlen, der ohne "${g.key}" auskommt.`,en:`[notification/unresolvedArg] The letter "${m.id}" always needs "${g.key}", but ${A.source.source} provides it only sometimes. Name a fixed value in notifications.${c.id}.args.${g.key} \u2014 or choose a letter that works without "${g.key}".`},severity:"error"});continue}if(A.status==="ambiguous"){t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/ambiguousArg] "${g.key}" hat mehrere passende Quellen \u2014 ${A.matches.map(I=>I.source).join(", ")}. In notifications.${c.id}.args.${g.key} einen Festwert setzen.`,en:`[notification/ambiguousArg] "${g.key}" has several matching sources \u2014 ${A.matches.map(I=>I.source).join(", ")}. Set a fixed value in notifications.${c.id}.args.${g.key}.`},severity:"error"});continue}t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/unresolvedArg] Der Brief "${m.id}" braucht "${g.key}"${g.type!==void 0?` (${Ol(g.type).de})`:""}, und der Knoten hat daf\xFCr ${A.rejected.length===0?"keine Quelle":`nur unpassende Quellen: ${A.rejected.map(I=>`${I.source} (${I.type})`).join(", ")}`}.`,en:`[notification/unresolvedArg] The letter "${m.id}" needs "${g.key}"${g.type!==void 0?` (${Ol(g.type).en})`:""}, and the node has ${A.rejected.length===0?"no source for it":`only unsuitable sources for it: ${A.rejected.map(I=>`${I.source} (${I.type})`).join(", ")}`}.`},severity:"error"})}}}}return t}s(wH,"checkNotificationBindings");function kH(e){return oN(e).map(n=>({layer:"GRAPH",kind:"assignment",path:"assignmentRules",reason:n,severity:"error"}))}s(kH,"checkAssignmentRules");function x_(e,n){let t=[...e.keys()].sort();return t.length===0?n==="de"?"(nichts)":"(nothing)":t.join(", ")}s(x_,"describeCandidates");function bH(e,n){return lN(e,n?.teamKeys).map(t=>({layer:"GRAPH",kind:"nodeRule",path:t.path,reason:t.reason,severity:"error"}))}s(bH,"checkChannels");function vH(e){return iI(e).map(n=>({layer:"GRAPH",kind:"nodeRule",path:n.path,reason:n.reason,severity:"error"}))}s(vH,"checkStaffInputs");function xH(e,n){let t=[];for(let r of e.nodes){let i=r.reads;if(i===void 0)continue;let o=`nodes.${r.id}.reads`,a={de:`Knoten \u201E${Oe(e,r.id,"de")}\u201C (${r.id})`,en:`Node "${Oe(e,r.id,"en")}" (${r.id})`},l=s(c=>{t.push({layer:"GRAPH",kind:"nodeRule",path:o,reason:c,severity:"error"})},"issue");if(!wN(r)){l({de:`[readiness/readsNotGated] ${a.de} (${r.type}) deklariert \`reads\`, aber die Bereitschaftspr\xFCfung h\xE4lt nur Entscheidungs-Knoten und Dokument-Knoten mit Produktion \u2014 hier w\xFCrde \`reads\` nichts bewirken.`,en:`[readiness/readsNotGated] ${a.en} (${r.type}) declares \`reads\`, but the readiness check only holds decision nodes and document nodes with production \u2014 here \`reads\` would have no effect.`});continue}if(!Array.isArray(i)){l({de:`[readiness/readsDuplicate] \`reads\` von ${a.de} muss eine Liste von Feldadressen sein, erhalten ${JSON.stringify(i)}.`,en:`[readiness/readsDuplicate] \`reads\` of ${a.en} must be a list of field addresses, got ${JSON.stringify(i)}.`});continue}let d=new Set;for(let c of i){if(!we(c))continue;let u=se(c);if(d.has(u)){l({de:`[readiness/readsDuplicate] ${a.de} liest ${Ve(e,c,"de")} mehrfach.`,en:`[readiness/readsDuplicate] ${a.en} reads ${Ve(e,c,"en")} more than once.`});continue}if(d.add(u),!fn(c)){l({de:`[readiness/readsUnknownField] ${a.de} liest ${Ve(e,c,"de")} \u2014 \`reads\` nennt nur Felder eines Formulars ($node.<formular>.admission.<feld>).`,en:`[readiness/readsUnknownField] ${a.en} reads ${Ve(e,c,"en")} \u2014 \`reads\` only names fields of a form ($node.<form>.admission.<field>).`});continue}let p=oi(n,c);p!=null&&Fs("nodeReads",Ds(p))==="repeated"&&l({de:`[readiness/readsUnknownField] ${a.de} liest ${Ve(e,c,"de")} \u2014 ein Feld in einer Wiederholgruppe ist kein einzelnes Feld der Anmeldung und kann nicht gelesen werden.`,en:`[readiness/readsUnknownField] ${a.en} reads ${Ve(e,c,"en")} \u2014 a field in a repeated group is not a single field of the application and cannot be read.`})}}return t}s(xH,"checkReadinessReads");function SH(e,n){let t=[];for(let r of e.nodes){if(r.type!=="setFlag")continue;let i=dO(r),o=xf(r);if(i===null||o===null)continue;let a=n?.formFlagKeysByFormNode?.get(i);if(a===void 0||a.has(o))continue;let l=[...a].sort();t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.inputs.${On.flagKey}`,reason:{de:`[setFlag/unknownFlag] Knoten \u201E${Oe(e,r.id,"de")}\u201C (${r.id}) setzt \u201E${o}\u201C, aber das Formular von \u201E${Oe(e,i,"de")}\u201C hat kein externes Merkmal dieses Namens`+(l.length>0?` (vorhanden: ${l.join(", ")}).`:" \u2014 es deklariert gar keins."),en:`[setFlag/unknownFlag] Node "${Oe(e,r.id,"en")}" (${r.id}) sets "${o}", but the form of "${Oe(e,i,"en")}" has no external flag of that name`+(l.length>0?` (present: ${l.join(", ")}).`:" \u2014 it declares none at all.")},severity:"error"})}return t}s(SH,"checkSetFlagKeys");function AH(e,n){let t=n?.readinessFormFieldsByFormNode,r=n?.readinessPartyConditionKeysByFormNode;if(t===void 0||r===void 0)return[];let i=[];for(let o of e.nodes){if(o.type!=="governedDocument"||o.production!=="resolver")continue;let a=o.form;if(!we(a)||!wr(a))continue;let l=t.get(a.owner),d=r.get(a.owner);if(l===void 0||d===void 0||d.size===0)continue;let c=vw(l,d);if(c.size===0)continue;let u=o.reads,p=(Array.isArray(u)?u:[]).filter(g=>fn(g)&&g.owner===a.owner),m=vw(l,[...p.map(g=>g.path),...vN(o).filter(g=>g.owner===a.owner).map(g=>g.fieldKey)]),y=[...c].filter(g=>!m.has(g)).sort();if(y.length===0)continue;let k={de:Oe(e,a.owner,"de"),en:Oe(e,a.owner,"en")};i.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${o.id}.reads`,reason:{de:`[readiness/readsMissesPartyCondition] Knoten \u201E${Oe(e,o.id,"de")}\u201C (${o.id}) erzeugt ein Dokument, dessen Vertragsparteien von Angaben im Formular \u201E${k.de}\u201C abh\xE4ngen, die er weder liest noch bindet: ${y.join(", ")}. Eine Korrektur darauf h\xE4lt den Knoten nicht an und kann nach der Ausstellung eine Vertragspartei entfernen \u2014 die Felder (oder den berechneten Schl\xFCssel) aus \u201E${k.de}\u201C in \`reads\` erg\xE4nzen.`,en:`[readiness/readsMissesPartyCondition] Node "${Oe(e,o.id,"en")}" (${o.id}) generates a document whose contract parties depend on answers in the form "${k.en}" that it neither reads nor binds: ${y.join(", ")}. A correction to them does not hold the node and can remove a contract party after issuing \u2014 add the fields (or the computed key) from "${k.en}" to \`reads\`.`},severity:"warning"})}return i}s(AH,"checkReadinessPartyConditions");function Dw(e){let n=Object.keys(e.inputs??{});if(n.length===0)return[];let t=e.generatorStamp,r=e.production,i=e.templateStamp;if(e.type==="governedDocument"&&(r==="resolver"&&!Array.isArray(t?.inputSchema?.fields)||r==="template"&&!Array.isArray(i?.fields)))return[];let a=new Set(Ks(e).map(l=>l.id));return n.filter(l=>!a.has(l))}s(Dw,"undeclaredInputKeys");function EH(e,n){return e.nodes.flatMap(t=>[...$H(e,t,Ks(t),n),...TH(e,t,n)])}s(EH,"checkUnknownResources");function TH(e,n,t){let r=[],i=new Set((He(n).workItemTemplates?.(n)??[]).map(o=>o.key));for(let o of Of(n)){if(o.leaf==="assign{}"&&!i.has(o.owner))continue;let a=_s[o.leaf],l=`nodes.${n.id}.${o.path}`,d=s(p=>p==="de"?`Knoten \u201E${Oe(e,n.id,"de")}\u201C (${n.id}), ${a.what.de} \u201E${o.owner}\u201C`:`node "${Oe(e,n.id,"en")}" (${n.id}), ${a.what.en} "${o.owner}"`,"where");if(o.missing){if(!a.required){r.push({layer:"GRAPH",kind:"nodeRule",path:l,severity:"error",reason:{de:`[inputs/emptyReference] ${d("de")}: der Eintrag ist leer oder kein Schl\xFCssel \u2014 ${a.consequence.de}. Team w\xE4hlen oder den Eintrag entfernen.`,en:`[inputs/emptyReference] ${d("en")}: the entry is empty or no key \u2014 ${a.consequence.en}. Choose a team or remove the entry.`}});continue}r.push({layer:"GRAPH",kind:"nodeRule",path:l,severity:"error",reason:{de:`[workItems/needsTeam] ${d("de")}: kein Team gew\xE4hlt \u2014 ${a.consequence.de}. Jede Aufgabe geh\xF6rt der Warteschlange eines Teams.`,en:`[workItems/needsTeam] ${d("en")}: no team chosen \u2014 ${a.consequence.en}. Every task belongs to a team's queue.`}});continue}if(o.key===null)continue;let c=t?.teamKeys;if(c===void 0||c.has(o.key))continue;let u=[...c].sort().join(", ")||"\u2014";r.push({layer:"GRAPH",kind:"nodeRule",path:l,severity:"error",reason:{de:`[inputs/unknownResource] ${d("de")}: \u201E${o.key}\u201C ist kein Team dieses Mandanten \u2014 ${a.consequence.de}. Teams: ${u}.`,en:`[inputs/unknownResource] ${d("en")}: "${o.key}" is no team of this school \u2014 ${a.consequence.en}. Teams: ${u}.`}})}return r}s(TH,"referenceIssues");function $H(e,n,t,r){let i=[];for(let o of t){if(!Sf(o.type))continue;let a=Is[o.type].existence;if(a.check!=="generic")continue;let l=r?.[a.catalog];if(l===void 0)continue;let d=n.inputs?.[o.id];if(d?.kind!=="literal"||typeof d.value!="string"||l.has(d.value))continue;let c=Is[o.type].label;i.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${n.id}.inputs.${o.id}`,reason:{de:`[inputs/unknownResource] Knoten \u201E${Oe(e,n.id,"de")}\u201C (${n.id}) nennt im Eingang \u201E${o.label.de}\u201C ${c.de} \u201E${d.value}\u201C \u2014 diesen Schl\xFCssel kennt dieser Mandant nicht.`,en:`[inputs/unknownResource] Node "${Oe(e,n.id,"en")}" (${n.id}) names the ${c.en.toLowerCase()} "${d.value}" in its input "${o.label.en}", which does not exist in this school.`},severity:"error"})}return i}s($H,"unknownResourceIssues");function RH(e){let n=[];for(let t of e.nodes)for(let r of Dw(t))n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${t.id}.inputs.${r}`,reason:{de:`[inputs/undeclared] Knoten \u201E${Oe(e,t.id,"de")}\u201C (${t.id}) hat einen Eingang \u201E${r}\u201C, den sein Typ nicht deklariert \u2014 ein Rest einer fr\xFCheren Einstellung (z. B. eines anderen Generators). Im Parameter-Bereich ist er nicht sichtbar; entfernen.`,en:`[inputs/undeclared] Node "${Oe(e,t.id,"en")}" (${t.id}) has an input "${r}" its type does not declare \u2014 a leftover of an earlier setting (e.g. another generator). It is not visible among the parameters; remove it.`},severity:"error"});return n}s(RH,"checkUndeclaredInputs");function IH(e){let n=[];for(let t of e.nodes){let r=new Set;for(let i of Ks(t)){if(!r.has(i.id)){r.add(i.id);continue}n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${t.id}.inputs.${i.id}`,reason:{de:`[inputs/duplicateSlot] Knoten \u201E${Oe(e,t.id,"de")}\u201C (${t.id}) hat den Eingang \u201E${i.id}\u201C zweimal \u2014 ein Parameter des Generators oder der Vorlage tr\xE4gt den Namen eines Eingangs des Knotentyps. Den Parameter umbenennen.`,en:`[inputs/duplicateSlot] Node "${Oe(e,t.id,"en")}" (${t.id}) has the input "${i.id}" twice \u2014 a parameter of the generator or template carries the name of an input of the node type. Rename the parameter.`},severity:"error"})}}return n}s(IH,"checkDuplicateSlots");function A_(e,n,t){let r=[],i=hH(e);if(i.length>0)return i;r.push(...eH(e)),r.push(...ZY(e)),r.push(...nH(e)),r.push(...XY(e)),r.push(...HY(e)),r.push(...JY(e)),r.push(...QY(e)),r.push(...rH(e)),r.push(...QO(e,n)),r.push(...iH(e,n)),r.push(...oH(e,n)),r.push(...sH(e,n)),r.push(...EN(e,n?.layout)),r.push(...aH(e,n)),r.push(...lH(e,n)),r.push(...cH(e,n)),r.push(...BO(e,t)),r.push(...nP(e)),r.push(...oP(e,t)),r.push(...XO(e)),r.push(...eP(e)),r.push(...RH(e)),r.push(...EH(e,t)),r.push(...IH(e)),r.push(...uH(e)),r.push(...fH(e)),r.push(...VN(e,t)),r.push(...YN(e)),r.push(...zN(e)),r.push(...HN(e,t)),r.push(...XN(e,t)),r.push(...mH(e)),r.push(...wH(e,t)),r.push(...gH(e,t)),r.push(...kH(e)),r.push(...xH(e,t)),r.push(...AH(e,t)),r.push(...SH(e,t)),r.push(...bH(e,t)),r.push(...vH(e)),r.push(...v_(e));for(let o of e.nodes){let a=He(o);a.validate&&r.push(...a.validate(o,e,t))}return r}s(A_,"checkGraph");function OH(e,n){let t=e.requiresOneOf;if(t===void 0)return[];let r=`nodes.${e.id}.requiresOneOf`,i=s(d=>({layer:"GRAPH",kind:"nodeRule",path:r,reason:d,severity:"error"}),"issue");if(e.type!=="decision")return[i({de:`[decision/requiresOneOfNotDecision] Knoten "${e.id}" (Typ "${e.type}") tr\xE4gt 'requiresOneOf' \u2014 die Regel gilt nur an Entscheidungsknoten (decision).`,en:`[decision/requiresOneOfNotDecision] Node "${e.id}" (type "${e.type}") carries 'requiresOneOf' \u2014 the rule only applies to decision nodes (decision).`})];if(!Array.isArray(t)||t.length===0||t.some(d=>typeof d!="string"||d.length===0))return[i({de:`[decision/requiresOneOfEmpty] 'requiresOneOf' an Knoten "${e.id}" muss eine nicht-leere Liste von Aktions-Keys sein \u2014 sonst Feld weglassen.`,en:`[decision/requiresOneOfEmpty] 'requiresOneOf' on node "${e.id}" must be a non-empty list of action keys \u2014 otherwise omit the field.`})];let o=n.map(d=>d.key).filter(d=>typeof d=="string"),a=[],l=new Set;for(let d of t){if(l.has(d)){a.push(i({de:`[decision/requiresOneOfDuplicate] 'requiresOneOf' an Knoten "${e.id}" nennt "${d}" doppelt.`,en:`[decision/requiresOneOfDuplicate] 'requiresOneOf' on node "${e.id}" names "${d}" twice.`}));continue}l.add(d),n.some(c=>c.key===d&&c.when!==void 0)&&a.push(i({de:`[decision/requiresOneOfConditional] 'requiresOneOf' an Knoten "${e.id}" nennt "${d}", das eine Bedingung ('when') tr\xE4gt \u2014 ist sie falsch, wird die Aktion nicht angeboten und die Entscheidung bliebe f\xFCr immer gesperrt.`,en:`[decision/requiresOneOfConditional] 'requiresOneOf' on node "${e.id}" names "${d}", which carries a condition ('when') \u2014 while it is false the action is not offered, and the decision would stay locked for good.`})),o.includes(d)||a.push(i({de:`[decision/requiresOneOfUnknownAction] 'requiresOneOf' an Knoten "${e.id}" nennt "${d}", aber dieser Knoten hat keine optionale Aktion mit diesem Key \u2014 die Regel w\xE4re nie erf\xFCllbar. `+(o.length===0?"Der Knoten hat keine optionalen Aktionen.":`Optionale Aktionen dieses Knotens: ${o.join(", ")}.`),en:`[decision/requiresOneOfUnknownAction] 'requiresOneOf' on node "${e.id}" names "${d}", but this node has no optional action with that key \u2014 the rule could never be met. `+(o.length===0?"The node has no optional actions.":`Optional actions of this node: ${o.join(", ")}.`)}))}return a}s(OH,"checkRequiresOneOf");function PH(e){return e.nodes.flatMap(n=>Dw(n).map(t=>({nodeId:n.id,key:t,binding:n.inputs?.[t]?.kind==="binding"})))}s(PH,"undeclaredInputCells");function E_(e,n){let t=PH(e).filter(o=>n.bindings||!o.binding);if(t.length===0)return{graph:e,dropped:t};let r=new Map;for(let o of t)r.set(o.nodeId,(r.get(o.nodeId)??new Set).add(o.key));let i=e.nodes.map(o=>{let a=r.get(String(o.id));if(a===void 0)return o;let l=Object.fromEntries(Object.entries(o.inputs).filter(([d])=>!a.has(d)));return{...o,inputs:l}});return{graph:{...e,nodes:i},dropped:t}}s(E_,"dropUndeclaredInputs");function Fw(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Fw,"isObject");function T_(e){return Fw(e)&&e.type==="governedDocument"&&("template"in e||"cockpitFields"in e)}s(T_,"oldShape");function $_(e){return(e?.nodes??[]).some(T_)}s($_,"needsTemplateStampMove");function NH(e){let n=e.generatorStamp?.inputSchema?.fields;if(e.production==="resolver")return Array.isArray(n)?n:null;let t=e.templateStamp?.fields;return e.production==="template"&&Array.isArray(t)?t:null}s(NH,"stampedFields");function _H(e){let n=String(e.id);if("template"in e&&"templateStamp"in e)return{unmoved:{nodeId:n,reason:"templateAndStamp"}};let t={...e},r=[];if("template"in e){let{template:i}=e;if(delete t.template,Fw(i))t.templateStamp={fields:Array.isArray(i.fields)?i.fields:[],...i.localeField===void 0?{}:{localeField:i.localeField}};else return{unmoved:{nodeId:n,reason:"templateNotObject"}}}if("cockpitFields"in e){let i=Array.isArray(e.cockpitFields)?e.cockpitFields.filter(l=>typeof l=="string"):[];delete t.cockpitFields;let o=Fw(e.inputs)?{...e.inputs}:{},a=NH(t);if(a===null&&i.length>0)return{unmoved:{nodeId:n,key:i[0],reason:"noStamp"}};for(let l of i){let d=l in o&&o[l]?.kind!=="unset",c=(a??[]).find(u=>u.key===l);if(c===void 0)r.push({nodeId:n,key:l,reason:"unknownKey"});else{if(c.type==="party"||c.type==="personList")continue;c.processSource!==void 0?r.push({nodeId:n,key:l,reason:"processSource"}):d?r.push({nodeId:n,key:l,reason:"cellExists"}):o[l]={kind:"cockpit"}}}t.inputs=o}return{node:t,reports:r}}s(_H,"moveNode");function R_(e){let n=[],t=[],r=[],i=e.nodes.map(o=>{if(!T_(o))return o;let a=_H(o);return"unmoved"in a?(r.push(a.unmoved),o):(n.push(String(o.id)),t.push(...a.reports),a.node)});return n.length===0?{graph:e,moved:n,reports:t,unmoved:r}:{graph:{...e,nodes:i},moved:n,reports:t,unmoved:r}}s(R_,"moveTemplateStampAndCockpit");var I_=ef,CH="applicant.applicationSubmitted";function bp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(bp,"isObject");function O_(e){return bp(e)&&e.type==="form"&&typeof e.id=="string"&&!vt(e)}s(O_,"isCreatingFormNode");function DH(e){return bp(e.notifications)&&I_ in e.notifications}s(DH,"hasSubmittedBinding");function Lw(e){let n={toBind:[],alreadyBound:[],malformed:[]};for(let t of e?.nodes??[])O_(t)&&(t.notifications!==void 0&&!bp(t.notifications)?n.malformed.push(t.id):DH(t)?n.alreadyBound.push(t.id):n.toBind.push(t.id));return n}s(Lw,"submitReceiptInventory");function P_(e){let{toBind:n}=Lw(e);if(n.length===0)return{graph:e,bound:[]};let t=new Set(n),r=e.nodes.map(i=>{if(!O_(i)||!t.has(i.id))return i;let o=bp(i.notifications)?i.notifications:{};return{...i,notifications:{...o,[I_]:{templateId:CH}}}});return{graph:{...e,nodes:r},bound:n}}s(P_,"bindSubmitReceipt");var No=["park","advance"],Xt="whenNothingOwed",N_={park:{de:"Jemand schaut drauf",en:"Someone looks at it"},advance:{de:"Durchreichen",en:"Pass through"}};function __(e){let n=e.inputs?.[Xt],t=n?.kind==="literal"?n.value:void 0;return Mw(t)?t:null}s(__,"reviewModeOrNull");function Mw(e){return No.includes(e)}s(Mw,"isReviewMode");function qw(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(qw,"isObject");function C_(e){return qw(e)&&e.type==="review"&&!(qw(e.inputs)&&Xt in e.inputs)}s(C_,"lacksMode");function D_(e){return(e?.nodes??[]).some(C_)}s(D_,"needsReviewMode");function F_(e){let n=[],t=e.nodes.map(r=>{if(!C_(r))return r;n.push(r.id);let i=qw(r.inputs)?r.inputs:{};return{...r,inputs:{...i,[Xt]:{kind:"literal",value:"park"}}}});return{graph:{...e,nodes:t},set:n}}s(F_,"setReviewModePark");function vp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(vp,"isObject");function L_(e){let{notifications:n,bound:t}=Gf(e.notifications,{tasks:[]},e);return{next:n,bound:t}}s(L_,"bindingsFor");function M_(e){let n={toBind:[],malformed:[]};for(let t of e?.nodes??[])if(!(!vp(t)||typeof t.id!="string"||Gs(t).length===0)){if(t.notifications!==void 0&&!vp(t.notifications)){n.malformed.push(t.id);continue}for(let r of L_(t).bound)n.toBind.push(`${t.id}.${r}`)}return n}s(M_,"appointmentLetterInventory");function q_(e){let n=[],t=!1,r=e.nodes.map(i=>{if(!vp(i)||typeof i.id!="string"||Gs(i).length===0||i.notifications!==void 0&&!vp(i.notifications))return i;let{next:o,bound:a}=L_(i);return a.length===0?i:(t=!0,n.push(...a.map(l=>`${i.id}.${l}`)),{...i,notifications:o})});return t?{graph:{...e,nodes:r},bound:n}:{graph:e,bound:[]}}s(q_,"bindAppointmentLetters");function ra(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(ra,"isObject");var K_=["id","label","dataFlow"],j_=["audience","populates","stages","expectedOutcomes"];function B_(e){return Array.isArray(e.assignmentRules)&&e.assignmentRules.some(n=>ra(n)&&typeof n.slot=="string")}s(B_,"carriesStringSlots");function V_(e){return(e.nodes??[]).some(n=>ra(n)&&n.type==="form"&&j_.some(t=>t in n))}s(V_,"carriesRetiredFormNodeKey");var FH=[{key:"generatorPin",editor:!0,holds:II,what:{de:"Generator als `resolver`",en:"generator as `resolver`"}},{key:"setFlagProperties",editor:!0,holds:mO,what:{de:"Formular und Merkmal eines \u201EFlag setzen\u201C-Knotens als Eigenschaften",en:'form and flag of a "Set flag" node as properties'}},{key:"scalarProperties",editor:!0,holds:bO,what:{de:"Einstellungen eines Knotens als Eigenschaften statt als Eing\xE4nge",en:"a node's settings as properties instead of inputs"}},{key:"nodeConfigProperties",editor:!0,holds:RO,what:{de:"Hinweis einer Zahlung als Eigenschaft oder ein entferntes Muster-Dokument",en:"a payment's note as a property, or a removed sample document"}},{key:"outcomeWithoutSemantic",editor:!0,holds:kI,what:{de:"Entscheidungsausg\xE4nge ohne Bedeutung",en:"decision outcomes without a meaning"}},{key:"startNodeOutcomes",editor:!0,holds:SI,what:{de:"ein Start-Knoten mit eigenen Ausg\xE4ngen",en:"a start node with its own outcomes"}},{key:"templateParameters",editor:!0,holds:$_,what:{de:"Parameter einer Vorlage am Knoten oder Cockpit-Felder als Liste",en:"a template's parameters on the node, or cockpit fields as a list"}},{key:"reviewWithoutMode",editor:!0,holds:D_,what:{de:"Pr\xFCfknoten ohne \u201EWenn nichts zu pr\xFCfen ist\u201C",en:'review nodes without "When nothing is owed"'}},{key:"taskAssignUser",editor:!1,holds:s(e=>If(e).length>0,"holds"),what:{de:"eine Aufgabe mit fester Person (`assign.userId`)",en:"a task with a fixed person (`assign.userId`)"}},{key:"retiredGraphKey",editor:!1,holds:s(e=>K_.some(n=>n in e),"holds"),what:{de:"`graph.id` / `graph.label` / `graph.dataFlow`",en:"`graph.id` / `graph.label` / `graph.dataFlow`"}},{key:"assignmentSlotString",editor:!1,holds:B_,what:{de:"Zust\xE4ndigkeitsregeln mit Slot als Text (`responsible` / `team:<Schl\xFCssel>`)",en:"assignment rules with a slot as text (`responsible` / `team:<key>`)"}},{key:"retiredFormNodeKey",editor:!1,holds:V_,what:{de:"Formularknoten mit `audience` / `populates` / `stages` / `expectedOutcomes`",en:"form nodes with `audience` / `populates` / `stages` / `expectedOutcomes`"}}];function U_(e){if(!ra(e)||!Array.isArray(e.nodes))return[];let n=e;return FH.filter(t=>t.holds(n)).map(({key:t,what:r,editor:i})=>({key:t,what:r,editor:i}))}s(U_,"legacyGraphShapes");function G_(e,n){let t=n.answers??{},r=[],i=[],o=e,a=K_.filter(T=>T in o);if(a.length>0){let T={...o};for(let b of a)delete T[b],r.push({message:`graph.${b}: deleted (read by nothing)`});o=T}if(V_(o)&&(o={...o,nodes:o.nodes.map(T=>{if(!ra(T)||T.type!=="form")return T;let b=j_.filter(q=>q in T);if(b.length===0)return T;let R={...T};for(let q of b)delete R[q];return r.push({nodeId:String(T.id),message:`form node: deleted ${b.map(q=>`\`${q}\``).join(", ")} (read by nothing)`}),R})}),B_(o)){let T=o.assignmentRules.map((b,R)=>{if(!ra(b)||typeof b.slot!="string")return b;let q=pf(b.slot);return q===null?(i.push({code:"assignment/slotUnknown",answer:"edit",message:`assignmentRules[${R}].slot "${b.slot}" is neither \`responsible\` nor \`team:<key>\` \u2014 edit it by hand`}),b):(r.push({message:`assignmentRules[${R}].slot "${b.slot}" \u2192 ${JSON.stringify(q)}`}),{...b,slot:q})});o={...o,assignmentRules:T}}let l=OI(o);o=l.graph;for(let T of l.moved)r.push({nodeId:T,message:"generator / template pin moved into its input"});for(let T of l.unmoved)i.push({code:`generatorPin/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`the generator or template pin cannot be moved (${T.reason}) \u2014 edit the node by hand`});let d=hO(o);o=d.graph;for(let T of d.moved)r.push({nodeId:T,message:"setFlag `target` / `flagKey` / `value` moved into its inputs"});for(let T of d.unmoved)i.push({code:`setFlag/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`the setFlag properties cannot be moved (${T.reason}) \u2014 edit the node by hand`});let c=vO(o);o=c.graph;for(let T of c.moved)r.push({nodeId:T,message:"scalar settings moved into inputs"});for(let T of c.unmoved)i.push({code:`scalar/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`\`${T.key}\` cannot be moved into an input (${T.reason}) \u2014 edit the node by hand`});let u=IO(o);o=u.graph;for(let T of u.moved)r.push({nodeId:T,message:"payment note moved into `inputs.reason` / retired sample document deleted"});for(let T of u.unmoved)i.push({code:`nodeConfig/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`\`${T.key}\` cannot be moved into an input (${T.reason}) \u2014 edit the node by hand`});let p=R_(o);o=p.graph;for(let T of p.moved){let b=o.nodes.find(P=>ra(P)&&P.id===T),R=b?.inputs?.documentTemplate,q=R?.kind==="literal"&&typeof R.value=="string"?R.value:null;r.push({nodeId:T,message:b!==void 0&&"templateStamp"in b&&q!==null?`template parameters moved onto \`templateStamp\` / cockpit list into cells \u2014 the record \`${q}\` must declare the same parameters (tenant catalog \`documentTemplates[].parameters\` / \`templates:setParameters\`) before publish, else [governedDocument/templateWithoutParameters]`:"cockpit list moved into `{ kind: 'cockpit' }` cells"})}for(let T of p.reports)r.push({nodeId:T.nodeId,message:`cockpit field \`${T.key??""}\` deleted (${T.reason}: ${T.reason==="unknownKey"?"the stamp declares no such parameter":T.reason==="processSource"?"the case fills it itself":"the input already holds a cell"})`});for(let T of p.unmoved)i.push({code:`templateStamp/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:T.reason==="noStamp"?"the cockpit list cannot be judged: the node carries no parameter stamp \u2014 run `offer workflow restamp-pins` against the environment, then upgrade again":T.reason==="templateAndStamp"?"the node carries both `template` and `templateStamp` \u2014 delete one by hand":"`template` is no object \u2014 edit the node by hand"});let m=AI(o);o=m.graph;for(let T of m.moved)r.push({nodeId:T,message:"start node: own `outcomes` / `event` / `effect` deleted (the node type declares its outcome)"});for(let T of m.unmoved)i.push({code:`eventTrigger/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`the start node cannot be reduced to its type's outcome (${T.reason}) \u2014 edit the node by hand`});let y=bI(o,t.semantics);o=y.graph;for(let T of y.written){if(T.source==="formerDefault"){r.push({nodeId:T.nodeId,message:`outcome \`${T.outcomeId}\`: semantic "${T.semantic}" (DEFAULT \u2014 the meaning it ran with; the retired id parser knew no other)`,defaulted:{answer:"semantic",answerKey:`${T.nodeId}.${T.outcomeId}`,value:T.semantic}});continue}r.push({nodeId:T.nodeId,message:`outcome \`${T.outcomeId}\`: semantic "${T.semantic}" (${T.source==="answer"?"answered":"the meaning the retired id parser gave this id"})`})}for(let T of y.refused)i.push({code:T.answer===void 0?"outcome/formerMeaningNotAllowed":"outcome/semanticNotAllowed",nodeId:T.nodeId,answer:"semantic",answerKey:`${T.nodeId}.${T.outcomeId}`,candidates:T.allowed,message:T.answer===void 0?`${T.nodeType} outcome \`${T.outcomeId}\` ran as "${fy(T.outcomeId)??""}", which a ${T.nodeType} outcome may no longer carry \u2014 say which one it is`:`${T.nodeType} outcome \`${T.outcomeId}\`: "${T.answer}" is not a meaning a ${T.nodeType} outcome may carry`});for(let T of y.invalid)i.push({code:"outcome/semanticInvalid",nodeId:T.nodeId,answer:"edit",candidates:bt,message:`outcome \`${T.outcomeId}\` carries the semantic "${T.value}", which is no meaning \u2014 edit it`});let k=$I(o,n.selection,t.waitlistPolicy);o=k.graph;for(let T of k.moved){let b=T.policy.waitlistOrder;r.push({nodeId:T.nodeId,message:`waitlist policy into inputs: ${LH(T.policy)} (${T.source==="answer"?"answered":T.source==="manifest"?"from manifest `selection`":"DEFAULT \u2014 the manifest stated no `selection.waitlistOrder`; the former code default it ran with"})`,...T.source==="formerDefault"?{defaulted:{answer:"waitlistPolicy",answerKey:T.nodeId,value:b}}:{}})}for(let T of k.refused)i.push({code:`waitlist/${T.reason}`,nodeId:T.nodeId,answer:"waitlistPolicy",answerKey:T.nodeId,candidates:Yt,message:"manifest `selection` is malformed \u2014 say the queue order of this waitlist"});if(PO(o)){let T=NO(o,t.payee);o=T.graph;for(let b of T.set)r.push({nodeId:b.nodeId,message:`online payment: payee "${b.payee}" (answered)`});for(let b of T.refused)i.push({code:"collectPayment/payeeMissing",nodeId:b,answer:"payee",answerKey:b,message:"an online payment names the Tr\xE4ger its money goes to \u2014 say its key (a `legal_entities.configKey` of the tenant)"})}for(let T of Lw(o).malformed)i.push({code:"submitReceipt/notificationsMalformed",nodeId:T,answer:"edit",message:"the form node's `notifications` is no record \u2014 edit it by hand"});let g=P_(o);o=g.graph;for(let T of g.bound)r.push({nodeId:T,message:"submit receipt bound to `notifications.submitted` (`applicant.applicationSubmitted`, sent by code before)"});let v=F_(o);o=v.graph;for(let T of v.set)r.push({nodeId:T,message:"review: `whenNothingOwed` = park (every review parked before the input existed)"});for(let T of M_(o).malformed)i.push({code:"appointmentLetters/notificationsMalformed",nodeId:T,answer:"edit",message:"the node's `notifications` is no record \u2014 edit it by hand"});let E=q_(o);o=E.graph;for(let T of E.bound){let b=T.indexOf(".");r.push({nodeId:T.slice(0,b),message:`appointment letter bound to \`notifications.${T.slice(b+1)}\` (the standard letter, sent by code before)`})}let A=If(o).filter(T=>!T.hasTeam);for(let T of A)i.push({code:"task/userWithoutTeam",nodeId:T.nodeId,answer:"edit",message:`task \`${T.taskKey}\` names a fixed person and no team \u2014 give it a team (\`assign.group\`) by hand`});let I=_O(o);o=I.graph;for(let T of I.dropped.filter(b=>b.hasTeam))r.push({nodeId:T.nodeId,message:`task \`${T.taskKey}\`: \`assign.userId\` deleted (the team holds the row)`});let _=E_(o,{bindings:!0});o=_.graph;for(let T of _.dropped){if(!T.binding){r.push({nodeId:T.nodeId,message:`input \`${T.key}\` deleted (no slot of the node declares it)`});continue}r.push({nodeId:T.nodeId,message:`input \`${T.key}\` deleted (DEFAULT \u2014 a binding no slot declares: no slot handed its value to the node, but the readiness gate waited for it; the node no longer waits for that value)`,defaulted:{answer:"undeclaredBinding",answerKey:`${T.nodeId}.${T.key}`,value:"deleted"}})}return{graph:o,changes:r,refusals:i}}s(G_,"upgradeGraph");function LH(e){return`waitlistOrder=${e.waitlistOrder}`}s(LH,"formatPolicy");function ui(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(ui,"isObject");var z_="admission.generic",W_=Object.keys(cf).filter(e=>e!=="label");function Y_(e){return ui(e.smartforms)?Object.entries(e.smartforms):[]}s(Y_,"smartformEntries");function MH(e){let n=[];Y_(e.index).some(([,i])=>ui(i)&&"outcomeFnRef"in i)&&n.push({de:"`smartforms.<slug>.outcomeFnRef` in bundle.yaml",en:"`smartforms.<slug>.outcomeFnRef` in bundle.yaml"});let t=Object.keys(e.manifest).filter(i=>Object.hasOwn(fl,i));if(t.length>0){let i=t.map(o=>`\`${o}\``).join(", ");n.push({de:`manifest.json mit ${i}`,en:`manifest.json with ${i}`})}Object.values(e.smartforms??{}).some(i=>W_.some(o=>o in i))&&n.push({de:"Formulardateien mit `id` / `outcomeIds` / `schoolSlug`",en:"form files with `id` / `outcomeIds` / `schoolSlug`"});let r=e.workflow;return r!==void 0&&(ui(r.progressWiring)&&"layoutId"in r.progressWiring&&n.push({de:"`progressWiring.layoutId`",en:"`progressWiring.layoutId`"}),n.push(...U_(r.graph).map(i=>i.what))),n}s(MH,"legacyBundleShapes");function Sp(e,n){let t=MH(e);t.length!==0&&le("BUNDLE_NEEDS_UPGRADE",{de:`offer: ${n} stammt aus einem \xE4lteren Bundle-Format (${t.map(r=>r.de).join("; ")}). Zuerst \`plexus-cli offer upgrade --dir <Bundle>\` ausf\xFChren (Probelauf, beantwortet die offenen Fragen), dann mit \`--write\` schreiben und erneut pr\xFCfen.`,en:`offer: ${n} is in an older bundle format (${t.map(r=>r.en).join("; ")}). Run \`plexus-cli offer upgrade --dir <bundle>\` first (a dry run that asks what it cannot decide), then write with \`--write\` and validate again.`})}s(Sp,"assertBundleCurrent");function xp(e){let n=s(t=>Array.isArray(t)?t.map(n):ui(t)?Object.fromEntries(Object.keys(t).sort().map(r=>[r,n(t[r])])):t,"sort");return JSON.stringify(n(e))}s(xp,"canonical");function H_(e,n={}){let t=[],r=[],i=e.index,o=Y_(i);if(o.some(([,u])=>ui(u)&&Object.keys(u).length>0)){let u={};for(let[p,m]of o){if(!ui(m)||Object.keys(m).length===0){u[p]=m;continue}let{outcomeFnRef:y,...k}=m;if(Object.keys(k).length>0||y!==void 0&&y!==z_){r.push({file:"bundle.yaml",code:"index/smartformEntry",answer:"edit",message:`smartforms.${p} carries ${Object.keys(m).map(g=>`\`${g}\``).join(", ")} \u2014 only \`outcomeFnRef: ${z_}\` is known; edit the entry to {} by hand`}),u[p]=m;continue}t.push({file:"bundle.yaml",message:`smartforms.${p}.outcomeFnRef deleted (a form routes by its own declared outcomes)`}),u[p]={}}i={...i,smartforms:u}}let a={},l=e.workflow,d;for(let[u,p]of Object.entries(e.manifest)){if(u==="selection"){d=p,t.push({file:"manifest.json",message:"`selection` deleted (its queue policy goes to the waitlist node's inputs; release strategy and deadline were read by nothing)"});continue}if(u==="progressLayout"){l===void 0?t.push({file:"manifest.json",message:"`progressLayout` deleted (the bundle has no workflow it could belong to)"}):l.progressLayout===void 0?(l={...l,progressLayout:p},t.push({file:"manifest.json",message:"`progressLayout` moved to workflow.json `progressLayout`"})):xp(l.progressLayout)===xp(p)?t.push({file:"manifest.json",message:"`progressLayout` deleted (workflow.json carries the same layout)"}):(r.push({file:"manifest.json",code:"manifest/progressLayoutTwice",answer:"edit",message:"`progressLayout` differs from workflow.json `progressLayout` \u2014 keep one by hand"}),a[u]=p);continue}let m=Object.hasOwn(fl,u)?fl[u]:void 0;if(m===void 0){r.push({file:"manifest.json",code:"manifest/unknownKey",answer:"edit",message:`unknown key \`${u}\` \u2014 manifest.json carries no key; decide by hand where it belongs`}),a[u]=p;continue}t.push({file:"manifest.json",message:`\`${u}\` deleted (${m.en})`})}if(l!==void 0){if(ui(l.progressWiring)&&"layoutId"in l.progressWiring){let{layoutId:p,...m}=l.progressWiring;l={...l,progressWiring:m},t.push({file:"workflow.json",message:"`progressWiring.layoutId` deleted (the layout is the workflow's own)"})}let u=l.graph;if(ui(u)&&Array.isArray(u.nodes)){let p=G_(u,{selection:d,answers:n});l={...l,graph:p.graph},t.push(...p.changes.map(m=>({...m,file:"workflow.json"}))),r.push(...p.refusals.map(m=>({...m,file:"workflow.json"})))}else r.push({file:"workflow.json",code:"workflow/graphShape",answer:"edit",message:"`graph` is no object with a node list"})}let c=e.smartforms;if(c!==void 0){let u={};for(let[p,m]of Object.entries(c)){let y={...m},k=`smartforms/${p}.json`;for(let g of W_)if(g in m){if(g==="outcomeIds"){let v=Array.isArray(m.outcomes)?m.outcomes.map(E=>ui(E)?E.id:void 0):[];if(xp([...Array.isArray(m.outcomeIds)?m.outcomeIds:[]].map(String).sort())!==xp(v.map(String).sort())){r.push({file:k,code:"smartform/outcomeIdsDiffer",answer:"edit",message:"`outcomeIds` differs from the ids of `outcomes[]` \u2014 reconcile them by hand"});continue}}delete y[g],t.push({file:k,message:`\`${g}\` deleted (${cf[g].en})`})}u[p]=y}c=u}return{bundle:{index:i,manifest:a,...c!==void 0?{smartforms:c}:{},...l!==void 0?{workflow:l}:{}},changes:t,refusals:r}}s(H_,"upgradeOfferBundle");var qH={createManifest:x.workflow.createManifest,publishManifest:x.workflow.publishManifest,publishOfferInternal:x.workflow.publishOfferInternal,publishOfferExternal:x.workflow.publishOfferExternal,getOfferPublishState:x.workflow.getOfferPublishState,upsertCustomField:x.admission.upsertCustomField,upsertDerivedAttributeRule:x.admission.upsertDerivedAttributeRule,createSmartForm:x.forms.createSmartForm,getSmartFormBySlug:x.forms.getSmartFormBySlug,saveSmartFormDraft:x.forms.saveSmartFormDraft,publishSmartForm:x.forms.publishSmartForm,createWorkflow:x.workflow.createWorkflow,getWorkflowGraph:x.workflow.getWorkflowGraph,saveWorkflowDraft:x.workflow.saveWorkflowDraft,publishWorkflow:x.workflow.publishWorkflow},Rye={createManifest:rt.workflow.createManifestInternal,publishManifest:rt.workflow.publishManifestInternal,publishOfferInternal:rt.workflow.publishOfferInternalInternal,publishOfferExternal:rt.workflow.publishOfferExternalInternal,getOfferPublishState:rt.workflow.getOfferPublishStateInternal,upsertCustomField:rt.admission.upsertCustomFieldInternal,upsertDerivedAttributeRule:rt.admission.upsertDerivedAttributeRuleInternal,createSmartForm:rt.forms.createSmartFormInternal,getSmartFormBySlug:rt.forms.getSmartFormBySlugInternal,saveSmartFormDraft:rt.forms.saveSmartFormDraftInternal,publishSmartForm:rt.forms.publishSmartFormInternal,createWorkflow:rt.workflow.createWorkflowInternal,getWorkflowGraph:rt.workflow.getWorkflowGraphInternal,saveWorkflowDraft:rt.workflow.saveWorkflowDraftInternal,publishWorkflow:rt.workflow.publishWorkflowInternal};function Kw(e,n){for(let[t,r]of Object.entries(e.smartforms??{})){(r===null||typeof r!="object"||Array.isArray(r))&&le("INVALID",{de:`offer: ${n}: smartforms.${t} muss eine leere Zuordnung ({}) sein.`,en:`offer: ${n}: smartforms.${t} must be an empty mapping ({}).`});let i=Object.keys(r);if(i.length===0)continue;let o=i.map(l=>`\`${l}\``).join(", "),a=i.includes("outcomeFnRef");le("INVALID",{de:`offer: ${n}: smartforms.${t} enth\xE4lt unbekannte Schl\xFCssel ${o} \u2014 der Eintrag muss leer sein ({}).${a?" `outcomeFnRef` geh\xF6rt nicht mehr zum Bundle-Format: ein Formular entscheidet \xFCber seine eigenen Ergebnisse. Die Zeile l\xF6schen.":""}`,en:`offer: ${n}: smartforms.${t} carries unknown key(s) ${o} \u2014 the entry must be empty ({}).${a?" `outcomeFnRef` is no longer part of the bundle format: a form routes by its own declared outcomes. Delete the line.":""}`})}}s(Kw,"assertSmartformEntries");function J_(e){let n=s(t=>Array.isArray(t)?t.map(n):t&&typeof t=="object"?Object.fromEntries(Object.keys(t).sort().map(r=>[r,n(t[r])])):t,"sort");return JSON.stringify(n(e))}s(J_,"canonicalJson");function Q_(e,n){return n==null?!0:J_(e)!==J_(n)}s(Q_,"changed");async function Z_(e,n,t,r={},i=qH){let{index:o}=n;Sp({index:o,manifest:n.manifest,...n.smartforms!==void 0?{smartforms:n.smartforms}:{},...n.workflow!==void 0?{workflow:n.workflow}:{}},`bundle of ${o.slugs.manifest}`),Kw(o,`bundle of ${o.slugs.manifest}`);let a=df(n.manifest);a.length>0&&le("INVALID",{de:`offer: manifest.json von ${o.slugs.manifest} ist ung\xFCltig:
|
|
11173
|
+
{{einstellungenLink}}`}}]},ow=[KW,zW,HW,JW,QW,e1,m1,g1,$1,I1,P1,C1,L1,q1,B1,G1,Y1,J1,y1,w1,k1,Q1,Z1,X1,n1,t1,i1,a1,f1,A1,k2,v2,BW,UW,n2,r2,o2,a2,c2,f2,m2];function sw(e){let n=ow.find(t=>t.id===e);return n===void 0&&F(`notifications: unknown letter "${e}"`),n}s(sw,"letterDefFor");function aw(e){return ow.some(n=>n.id===e)}s(aw,"hasLetterDef");function lw(e,n){return n===void 0?!0:Af(e,n)}s(lw,"letterArgCompatible");function Ol(e){return e==="localizedText"?{de:"Text in jeder Sprache (localizedText)",en:"Text in every language (localizedText)"}:{de:`${xt(e)} (${e})`,en:`${xt(e)} (${e})`}}s(Ol,"letterArgTypeLabel");function SP(e){let n=new Map,t=s((r,i)=>{let o=n.get(r);o===void 0?n.set(r,[i]):o.push(i)},"add");for(let r of e.args)t(r.key,{source:`Ereignis "${e.id}"`,type:r.type,always:r.required===!0});for(let r of dP)t(r.key,{source:"Kontext des Versands",type:r.type,always:!0});return n}s(SP,"eventArgSources");function AP(e,n){let t=e.type===void 0?[...n]:n.filter(r=>lw(r.type,e.type));if(t.length>1)return{status:"ambiguous",matches:t};if(t.length===1){let r=t[0];return!e.required||r.always?{status:"resolved",source:r}:{status:"sometimes",source:r}}return e.required?{status:"missing",rejected:[...n]}:{status:"unused"}}s(AP,"resolveLetterParam");var dw=["booked","rescheduled","cancelled"],x2={booked:"admission.appointmentBooked",rescheduled:"admission.appointmentRescheduled",cancelled:"admission.appointmentCancelled"},TP=":";function $P(e,n){return`${e}${TP}${n}`}s($P,"appointmentEventId");function S2(e){let n=e.lastIndexOf(TP);if(n<=0)return null;let t=e.slice(n+1);return dw.includes(t)?{taskKey:e.slice(0,n),kind:t}:null}s(S2,"parseAppointmentEventId");var EP={booked:{de:"Termin vereinbart",en:"Appointment booked"},rescheduled:{de:"Termin verschoben",en:"Appointment moved"},cancelled:{de:"Termin abgesagt",en:"Appointment cancelled"}};function Gs(e){return Array.isArray(e.tasks)?e.tasks.filter(n=>typeof n?.key=="string"&&n.result?.kind==="appointment"):[]}s(Gs,"appointmentTasksOf");function A2(e){return dw.map(n=>({id:$P(e.key,n),label:{de:`${EP[n].de} \u2013 \u201E${e.title.de}\u201C`,en:`${EP[n].en} \u2013 \u201C${e.title.en}\u201D`},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"bookingId",type:"string",required:!0}]}))}s(A2,"appointmentTaskEvents");function RP(e,n){let t=n.notificationEvents?.(e)??[],r=Gs(e).flatMap(A2);return r.length===0?t:[...t,...r]}s(RP,"nodeNotificationEvents");function E2(e){return Object.fromEntries(dw.map(n=>[$P(e,n),{templateId:x2[n]}]))}s(E2,"defaultAppointmentBindings");function T2(e,n){if(e===void 0)return{notifications:e,dropped:[]};let t=[],r={};for(let[i,o]of Object.entries(e))S2(i)?.taskKey===n?t.push(i):r[i]=o;return t.length===0?{notifications:e,dropped:t}:{notifications:Object.keys(r).length===0?void 0:r,dropped:t}}s(T2,"withoutAppointmentBindings");function Gf(e,n,t){let r=new Set(Gs(n).map(d=>d.key)),i=new Set(Gs(t).map(d=>d.key)),o=e,a=[];for(let d of r){if(i.has(d))continue;let c=T2(o,d);o=c.notifications,a.push(...c.dropped)}let l=[];for(let d of i)if(!r.has(d))for(let[c,u]of Object.entries(E2(d)))o?.[c]===void 0&&(o={...o??{},[c]:u},l.push(c));return{notifications:o,bound:l,dropped:a}}s(Gf,"syncAppointmentBindings");function $2(e){return e.kind==="task"&&!("title"in e)}s($2,"isLegacyFreeTodoContext");function cw(e){let{context:n}=e;if($2(n)&&F(`[workItems/legacyFreeTodo] work_item ${e._id} is a free to-do in its former shape \u2014 run migrations:freeTodosToContext`),n.kind==="task")return{...e,context:n,kind:"task",createdVia:"human",partyId:n.partyId};let{anchor:t,task:r,kind:i,title:o,description:a,...l}=n,d=t.scope==="node"?{nodeId:t.nodeId,templateKey:t.templateKey,gatesNode:t.gatesNode,blocks:t.blocks}:t.scope==="application"?{scope:"application",templateKey:t.templateKey}:t.scope==="crossNode"?{scope:"application",nodeId:t.nodeId,templateKey:t.templateKey,blocks:t.blocks}:{};return{...e,context:n,...l,...d,...r??{},kind:i}}s(cw,"readWorkItem");async function Pl(e,n){let t;if(n.nodeId!==void 0){let r=n.nodeId;t=await e.db.query("work_items").withIndex("by_applicationId_and_nodeId",i=>i.eq("context.applicationId",n.applicationId).eq("context.anchor.nodeId",r)).collect()}else if(n.isOpen!==void 0){let r=n.isOpen;t=await e.db.query("work_items").withIndex("by_applicationId_and_isOpen",i=>i.eq("context.applicationId",n.applicationId).eq("isOpen",r)).collect()}else t=await e.db.query("work_items").withIndex("by_applicationId_and_nodeId",r=>r.eq("context.applicationId",n.applicationId)).collect();return t.filter(r=>n.isOpen===void 0||r.isOpen===n.isOpen).map(cw)}s(Pl,"listWorkItemsForApplication");var Kfe=w.union(w.literal("approved"),w.literal("rejected")),Nl=new Set(["task","approval"]);function R2(e,n){switch(e){case"task":return n?.gatesNode===!0&&F("expandComposedTask: gatesNode is approval-only \u2014 a 'task' template never gates its node (use blocks to hold a gating sibling back)"),{kind:"task",recipient:"internal",gatesNode:!1};case"approval":return{kind:"approval",recipient:"internal",isApproval:!0,gatesNode:n?.gatesNode??!0};default:F(`expandComposedTask: unknown composed-task kind ${JSON.stringify(e)} \u2014 authorable: ${[...Nl].join(", ")}`)}}s(R2,"expandComposedTask");for(let e of["task","approval"]){let n=R2(e);n.kind==="approval"!=(n.isApproval===!0)&&F(`composed-task kind "${e}": isApproval must be present iff kind === 'approval'`)}var IP=Ri,qi=`${IP}.`,I2=new Set(["text","number","date","boolean","option","edge"]);function zf(e,n){let t=e[n];return t===void 0&&F(`[env/unknownKey] no environment key '${n}'`),typeof t=="string"?null:Object.keys(t)}s(zf,"contextFields");function OP(e,n){return Object.hasOwn(e,n)}s(OP,"isContextKey");function PP(e){let n=[];for(let t of Object.keys(e)){let r=zf(e,t);if(r===null)n.push(t);else for(let i of r)n.push(`${t}.${i}`)}return n}s(PP,"leafPaths");function _l(e,n){let[t="",r,...i]=n.split(".");if(!OP(e,t)||i.length>0)return;let o=e[t];if(typeof o=="string")return r===void 0?o:void 0;if(!(r===void 0||!Object.hasOwn(o,r)))return o[r]}s(_l,"leafType");function NP(e){let n=new Set;for(let t of e){let r=zs(t);r!==null&&n.add(r.split(".")[0])}return[...n]}s(NP,"contextKeysOf");function zs(e){return e.startsWith(qi)?e.slice(qi.length):null}s(zs,"contextPathOf");function Cl(e){return e===IP||e.startsWith(qi)}s(Cl,"isContextIdentifier");function Wf(e,n){let t=zs(n)??"",[r=""]=t.split("."),i=Object.keys(e);if(!OP(e,r))return{code:"env/unknownKey",message:{de:`'${n}' nennt keinen Umgebungsschl\xFCssel \u2014 bekannt: ${i.join(", ")}.`,en:`'${n}' names no environment key \u2014 known: ${i.join(", ")}.`}};if(_l(e,t)!==void 0)return null;let o=zf(e,r);return{code:"env/unknownKey",message:o===null?{de:`'${n}': der Umgebungsschl\xFCssel '${r}' ist ein einzelner Wert \u2014 lies ihn als '${qi}${r}'.`,en:`'${n}': environment key '${r}' is a single value \u2014 read it as '${qi}${r}'.`}:{de:`'${n}': der Umgebungsschl\xFCssel '${r}' hat die Felder ${o.join(", ")}.`,en:`'${n}': environment key '${r}' has the fields ${o.join(", ")}.`}}}s(Wf,"identifierIssue");function Yf(e,n,t=Object.keys(e)){let r={};for(let i of t){let o=zf(e,i),a=Object.hasOwn(n,i)?n[i]:void 0;if(a===void 0&&F(`[env/missing] context key '${i}' was not supplied`),o===null){r[`${qi}${i}`]=a;continue}for(let l of o){let d=typeof a=="object"&&a!==null&&Object.hasOwn(a,l)?a[l]:void 0;d===void 0&&F(`[env/missing] context key '${i}' carries no '${l}'`),r[`${qi}${i}.${l}`]=d}}return r}s(Yf,"flatten");function _P(e,n,t){if(t===void 0)return!1;let r=zf(e,n);return r===null?!0:typeof t=="object"&&t!==null&&r.every(i=>t[i]!==void 0)}s(_P,"contextValueComplete");function O2(e,n){switch(n){case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";case"date":return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}/.test(e);default:return typeof e=="string"}}s(O2,"valueMatchesDataType");function CP(e,n,t=Object.keys(e.types)){let r=new Set(t);for(let i of PP(e.types)){if(!r.has(i.split(".")[0]))continue;let o=n[`${qi}${i}`];o===void 0&&F(`[env/missing] context path '${i}' was not supplied`);let a=e.fields[i];if(o===null){a.nullable||F(`[env/null] context path '${i}' is not nullable but carries null`);continue}let l=xt(_l(e.types,i));O2(o,l)||F(`[env/type] context path '${i}' expects ${l}, got ${JSON.stringify(o)}`),a.valueSet.kind==="fixed"&&!a.valueSet.values.includes(o)&&F(`[env/value] context path '${i}' carries '${String(o)}', outside ${a.valueSet.values.join(" | ")}`)}}s(CP,"assertContextValues");function P2(e){let n=[],t=PP(e.types);for(let r of t){let i=_l(e.types,r),o=xt(i);if(!_i(i)||o===void 0||!I2.has(o)){n.push(`'${r}' has type '${String(i)}', not a scalar value type`);continue}let a=Object.hasOwn(e.fields,r)?e.fields[r]:void 0;if(a===void 0){n.push(`'${r}' has no field spec (value set + nullability)`);continue}a.valueSet.kind==="fixed"&&(a.valueSet.values.length===0&&n.push(`'${r}' has an empty fixed value set`),o!=="text"&&o!=="option"&&n.push(`'${r}' is ${o}; a fixed value set needs a text or option leaf`))}for(let r of Object.keys(e.fields))t.includes(r)||n.push(`field spec '${r}' names no leaf of the schema`);return n}s(P2,"schemaIssues");function Ws(e){let n=P2(e);n.length>0&&F(`[env/schema] ${n.join("; ")}`)}s(Ws,"assertSchema");var Hf={length:{params:["text"],returns:"number"},years_between:{params:["date","date"],returns:"number"}};function Ki(e){return JSON.stringify(e)}s(Ki,"canonical");function Hs(e){return e.kind==="binary"&&e.op==="&&"?[...Hs(e.left),...Hs(e.right)]:[e]}s(Hs,"conjuncts");function LP(e,n){let t;try{t=In(e)}catch{return!1}let r=Ki(In(n));return Hs(t).some(i=>Ki(i)===r)}s(LP,"hasConjunct");function MP(e,n){try{return Ki(In(e))===Ki(In(n))}catch{return!1}}s(MP,"sameCondition");function qP(e){let n=[];for(let t of e)n.push(...xn(gr(t)));return NP(n)}s(qP,"contextKeysRead");function KP(e){try{return xn(In(e)).some(Cl)}catch{return!1}}s(KP,"readsContext");var N2=/^\d{4}-\d{2}-\d{2}$/,_2=new Set(["==","!=","<","<=",">",">=","in"]),C2=new Set(["<","<=",">",">="]);function Qf(e,n,t=[]){Ws(n);let r;try{r=In(e)}catch(a){let l=a.message;return[zn("condition/parse",`Bedingung '${e}' ist nicht lesbar: ${l}`,`condition '${e}' does not parse: ${l}`)]}let i=[];for(let a of xn(r)){if(!Cl(a)){i.push(zn("condition/foreignIdentifier",`'${a}' ist kein Umgebungswert \u2014 Bedingungen lesen nur '$env.*'`,`'${a}' is not a context identifier \u2014 conditions read only '$env.*'`));continue}let l=Wf(n.types,a);l!==null&&i.push(zn("condition/unknownIdentifier",l.message.de,l.message.en))}if(i.length>0)return i;let o=Lr(r,n,i);Dl(o)||i.push(zn("condition/notBoolean",`Bedingung '${e}' ist kein Ja/Nein-Ausdruck`,`condition '${e}' is not a yes/no expression`)),M2(r,n,i);for(let{identifier:a,op:l}of pw(r,n))i.push(zn("condition/unguardedNullable",`'${l}' \xFCber '${a}', das leer sein kann, braucht davor eine Absicherung '${a} != null &&'`,`'${l}' over '${a}', which may be null, needs a guard '${a} != null &&' before it`));return i.push(...D2(r,t)),i}s(Qf,"conditionIssues");function D2(e,n){let t=Hs(e).map(Ki);return n.flatMap(r=>{let i=In(r),o=F2(i);return o===null||!t.includes(Ki(o))?[]:[{severity:"info",code:"condition/guardForm",message:{de:`[condition/guardForm] eine gespiegelte Absicherung z\xE4hlt nicht \u2014 schreibe sie genau als '${r}'`,en:`[condition/guardForm] a mirrored guard does not count \u2014 write it exactly as '${r}'`}}]})}s(D2,"guardFormHints");function F2(e){if(e.kind!=="binary"||e.op!=="=="&&e.op!=="!=")return null;let n={...e,left:e.right,right:e.left};return Ki(n)===Ki(e)?null:n}s(F2,"mirror");function Dl(e){return e.t==="unknown"||e.t==="data"&&e.dt==="boolean"}s(Dl,"isBooleanish");function jP(e){let n=zs(e);return n===null&&F(`[condition/invariant] '${e}' reached a pass that only sees $env identifiers`),n}s(jP,"contextPath");function BP(e,n){let t=zs(n);return t!==null&&e.fields[t]?.nullable===!0}s(BP,"isNullableLeaf");function L2(e,n){let t=xt(_l(e.types,jP(n)));return t===void 0?{t:"unknown"}:{t:"data",dt:t}}s(L2,"identType");function Jf(e,n){return e.t==="unknown"||n.t==="unknown"||e.t==="null"||n.t==="null"?!0:e.t==="array"||n.t==="array"?!1:e.t==="str"&&n.t==="str"?!0:e.t==="str"?DP(e.value,n.dt):n.t==="str"?DP(n.value,e.dt):e.dt===n.dt}s(Jf,"fits");function DP(e,n){return n==="text"||n==="option"||n==="edge"?!0:n==="date"?N2.test(e):!1}s(DP,"strFits");function FP(e){return e.t==="unknown"?"unknown":e.t==="data"&&e.dt==="number"?"number":null}s(FP,"orderedCategory");function Lr(e,n,t){switch(e.kind){case"num":return{t:"data",dt:"number"};case"bool":return{t:"data",dt:"boolean"};case"str":return{t:"str",value:e.value};case"null":return{t:"null"};case"ident":return L2(n,e.path);case"arr":for(let r of e.items)Lr(r,n,t);return{t:"array"};case"unary":{let r=Lr(e.operand,n,t);return Dl(r)||t.push(zn("condition/notBoolean","'!' braucht einen Ja/Nein-Operanden","'!' needs a yes/no operand")),{t:"data",dt:"boolean"}}case"call":{let r=Object.hasOwn(Hf,e.name)?Hf[e.name]:void 0,i=e.args.map(l=>Lr(l,n,t));return r===void 0?(t.push(zn("condition/functionNotAllowed",`Funktion '${e.name}' ist nicht erlaubt \u2014 erlaubt: ${Object.keys(Hf).join(", ")}`,`function '${e.name}' is not allowed \u2014 allowed: ${Object.keys(Hf).join(", ")}`)),{t:"unknown"}):(i.length===r.params.length&&i.every((l,d)=>l.t!=="null"&&Jf(l,{t:"data",dt:r.params[d]}))||t.push(zn("condition/typeMismatch",`'${e.name}' nimmt (${r.params.join(", ")})`,`'${e.name}' takes (${r.params.join(", ")})`)),{t:"data",dt:r.returns})}case"if":{let r=Lr(e.cond,n,t);Dl(r)||t.push(zn("condition/notBoolean","'if' braucht eine Ja/Nein-Bedingung","'if' needs a yes/no condition"));let i=Lr(e.then,n,t),o=Lr(e.else,n,t);return Jf(i,o)||t.push(zn("condition/typeMismatch","die beiden Zweige von 'if' haben verschiedene Typen","the two arms of 'if' differ in type")),i.t==="null"?o:i}case"binary":{let r=Lr(e.left,n,t),i=Lr(e.right,n,t);if(e.op==="&&"||e.op==="||")(!Dl(r)||!Dl(i))&&t.push(zn("condition/notBoolean",`'${e.op}' braucht Ja/Nein-Operanden`,`'${e.op}' needs yes/no operands`));else if(e.op==="in")e.right.kind!=="arr"?t.push(zn("condition/inWithoutArray","'in' braucht rechts eine Liste, z. B. ['a', 'b']","'in' needs a list on its right, e.g. ['a', 'b']")):e.right.items.every(o=>Jf(r,Lr(o,n,[])))||t.push(zn("condition/typeMismatch","ein Listeneintrag von 'in' passt nicht zum Typ des linken Operanden","a list item of 'in' does not match the left operand's type"));else if(C2.has(e.op)){let o=FP(r),a=FP(i);(o===null||a===null||o!=="unknown"&&a!=="unknown"&&o!==a)&&t.push(zn("condition/orderedComparison",`'${e.op}' vergleicht nur Zahlen \u2014 f\xFCr Daten years_between(\u2026) verwenden`,`'${e.op}' compares only numbers \u2014 for dates use years_between(\u2026)`))}else Jf(r,i)||t.push(zn("condition/typeMismatch",`'${e.op}' vergleicht Werte verschiedener Typen`,`'${e.op}' compares values of different types`));return{t:"data",dt:"boolean"}}}}s(Lr,"typeOf");function uw(e){return e.kind==="str"||e.kind==="num"||e.kind==="bool"}s(uw,"isLiteral");function VP(e){let n=[],t=s(r=>{if(r.kind==="binary"&&_2.has(r.op)){if(r.left.kind==="ident"){let i=r.op==="in"&&r.right.kind==="arr"?r.right.items.filter(uw):uw(r.right)?[r.right]:[];i.length>0&&n.push({ident:r.left.path,literals:i})}r.right.kind==="ident"&&uw(r.left)&&n.push({ident:r.right.path,literals:[r.left]})}UP(r,t)},"visit");return t(e),n}s(VP,"comparedLiterals");function M2(e,n,t){for(let{ident:r,literals:i}of VP(e)){let o=q2(r,i,n);o!==null&&t.push(o)}}s(M2,"literalIssues");function fw(e,n){let t;try{t=In(e)}catch{return[]}let r=[];for(let{ident:i,literals:o}of VP(t)){let a=zs(i);if(!(a===null||n.fields[a]?.valueSet.kind!=="live"))for(let l of o)l.kind==="str"&&r.push({path:a,value:l.value})}return r}s(fw,"liveLiterals");function q2(e,n,t){let r=t.fields[jP(e)]?.valueSet;if(r?.kind==="unstable")return zn("condition/literalOnUnstable",`'${e}' ist nicht \xFCber Umgebungen stabil \u2014 vergleiche ihn mit keinem festen Wert; verzweige stattdessen \xFCber ein stabiles Merkmal`,`'${e}' is not stable across environments \u2014 compare it to no literal; branch on a stable attribute instead`);if(r?.kind!=="fixed")return null;let i=n.flatMap(a=>a.kind==="str"&&!r.values.includes(a.value)?[`'${a.value}'`]:[]);if(i.length===0)return null;let o=r.values.map(a=>`'${a}'`).join(", ");return zn("condition/literalOutsideSet",`'${e}' kennt nur ${o} \u2014 nicht ${i.join(", ")}`,`'${e}' takes only ${o} \u2014 not ${i.join(", ")}`)}s(q2,"valueSetIssue");function UP(e,n){switch(e.kind){case"binary":n(e.left),n(e.right);return;case"unary":n(e.operand);return;case"call":e.args.forEach(n);return;case"arr":e.items.forEach(n);return;case"if":n(e.cond),n(e.then),n(e.else);return;default:return}}s(UP,"forEachChild");function GP(e){return e.kind==="binary"&&(e.op==="=="||e.op==="!=")&&(e.left.kind==="ident"&&e.right.kind==="null"||e.left.kind==="null"&&e.right.kind==="ident")}s(GP,"isNullTest");function zP(e){return Hs(e).flatMap(n=>{let t=WP(n);return t===null?[]:[t]})}s(zP,"guardsOf");function Fl(e,n,t){switch(e.kind){case"ident":return BP(n,e.path)&&!t.has(e.path)?e.path:null;case"call":for(let r of e.args){let i=Fl(r,n,t);if(i!==null)return i}return null;case"if":return Fl(e.then,n,new Set([...t,...zP(e.cond)]))??Fl(e.else,n,t);default:return null}}s(Fl,"unguardedNullSource");function WP(e){return!GP(e)||e.kind!=="binary"||e.op!=="!="?null:e.left.kind==="ident"?e.left.path:e.right.kind==="ident"?e.right.path:null}s(WP,"guardedIdent");function Ys(e,n,t,r){if(e.kind==="binary"&&e.op==="&&"){let i=new Set(t);for(let o of Hs(e)){Ys(o,n,i,r);let a=WP(o);a!==null&&i.add(a)}return}if(e.kind==="if"){Ys(e.cond,n,t,r),Ys(e.then,n,new Set([...t,...zP(e.cond)]),r),Ys(e.else,n,t,r);return}if(e.kind==="binary"&&e.op==="!="&&e.left.kind!=="null"&&e.right.kind!=="null"){let i=Fl(e.left,n,t)??Fl(e.right,n,t);i!==null&&r(i,"!=")}if(e.kind==="unary"&&!GP(e.operand)){let i=xn(e.operand).filter(o=>BP(n,o)&&!t.has(o));i.length>0&&r(i[0],"!")}UP(e,i=>Ys(i,n,t,r))}s(Ys,"nullableReads");function pw(e,n){Ws(n);let t=[];return Ys(e,n,new Set,(r,i)=>{t.some(o=>o.identifier===r)||t.push({identifier:r,op:i})}),t}s(pw,"unguardedNullableReads");function zn(e,n,t){return{severity:"error",code:e,message:{de:`[${e}] ${n}`,en:`[${e}] ${t}`}}}s(zn,"error");function Ll(e){let n=Array.isArray(e.nodes)?e.nodes:[],t=new Set;for(let r of n)for(let i of Of(r))i.key!==null&&_s[i.leaf].involves&&t.add(i.key);return t}s(Ll,"declaredGroupKeys");var Js=rf;var K2="unit.key",j2="offer.key";function YP(e,n){return e===K2?n.unitKeys:e===j2?n.offerKeys:null}s(YP,"liveKeyUniverse");function Zf(e){return[wn,...[...Ll(e)].sort((n,t)=>n.localeCompare(t)).map(uf)]}s(Zf,"requiredSlots");var ji=`${sf("applicant.channel")} == 'staff'`;var hw=["strict","leastLoaded"];var mw=2;function HP(e){return e.some(n=>n.length===0)?{de:"nennt einen leeren Personenschl\xFCssel",en:"names an empty person key"}:new Set(e).size!==e.length?{de:"nennt eine Person zweimal",en:"names a person twice"}:e.length<mw?{de:`braucht mindestens ${mw} Personen`,en:`needs at least ${mw} people`}:null}s(HP,"rotationPoolProblem");function B2(e,n){let t=n===null?-1:e.indexOf(n);return[...e.slice(t+1),...e.slice(0,t+1)]}s(B2,"strictOrder");function JP(e){let n=B2(e.pool,e.previous).filter(i=>e.eligible.has(i));if(n.length===0)return null;if(e.mode==="strict")return n[0];let t=e.openCounts;t===void 0&&F("[assignment/rotation] leastLoaded needs the open counts");let r=s(i=>{let o=t.get(i);return o===void 0&&F(`[assignment/rotation] no open count for '${i}'`),o},"load");return n.reduce((i,o)=>r(o)<r(i)?o:i)}s(JP,"pickFromPool");function ZP(e){return e.map(n=>({slot:mI(n.slot),rules:[...n.rules]}))}s(ZP,"rulesOfStored");function XP(e){return e.map(n=>({slot:V2(n.slot),rules:[...n.rules]}))}s(XP,"storedOfRules");function V2(e){let n=pf(e);return n===null&&F(`[assignment/unknownSlot] '${e}' is no slot \u2014 'responsible' or 'team:<teamKey>'`),n}s(V2,"slotOf");function eN(e,n){let t=e?.assignmentRules;t===void 0&&F(`[assignment/noRules] ${n}: the workflow has no assignment rule`);let r=iN(t);return r.length>0&&F(`${r.join("; ")} (${n})`),ZP(t)}s(eN,"rulesOfGraph");function U2(e){return e===wn?{slot:e,rules:[{when:ji,assign:{kind:"creator"}},{when:null,assign:{kind:"unassigned"}}]}:{slot:e,rules:[{when:null,assign:{kind:"queue"}}]}}s(U2,"defaultSlotRules");function nN(e,n){let t=new Set(e.map(o=>o.slot)),r=n.filter(o=>!t.has(o)).map(U2);return[...r.filter(o=>o.slot===wn),...e,...r.filter(o=>o.slot!==wn)]}s(nN,"withRequiredSlots");function Nn(e,n){return n===void 0?`slot '${e}'`:`slot '${e}' row #${n+1}`}s(Nn,"where");function Nt(e,n){return n===void 0?`Liste '${e}'`:`Liste '${e}', Zeile #${n+1}`}s(Nt,"whereDe");function St(e,n,t={},r="error"){return{severity:r,code:e,message:{de:`[${e}] ${n.de}`,en:`[${e}] ${n.en}`},...t}}s(St,"issue");function QP(e){if(e===wn)return!0;let n=ff(e);return n!==null&&n.length>0}s(QP,"isKnownSlot");function G2(e,n){Ws(Js);let t=[],r=new Set;e.forEach((o,a)=>{let{slot:l}=o;QP(l)||t.push(St("assignment/unknownSlot",{de:`'${l}' ist keine Liste \u2014 'responsible' oder 'team:<teamKey>'`,en:`'${l}' is no slot \u2014 'responsible' or 'team:<teamKey>'`},{slot:l})),r.has(l)&&t.push(St("assignment/duplicateSlot",{de:`${Nt(l)} steht zweimal da`,en:`${Nn(l)} is listed twice`},{slot:l})),r.add(l),l===wn&&a!==0&&t.push(St("assignment/responsibleFirst",{de:`'${wn}' muss die erste Liste sein \u2014 Team-Zeilen \xFCbernehmen sie`,en:`'${wn}' must be the first slot \u2014 team rows copy it`},{slot:l})),t.push(...z2(o))});for(let o of n)r.has(o)||t.push(St("assignment/slotMissing",{de:`${Nt(o)} hat keine Regeln \u2014 der Workflow braucht sie`,en:`${Nn(o)} has no rule list \u2014 the workflow needs it`},{slot:o}));let i=new Set(n);for(let{slot:o}of e)o!==wn&&!i.has(o)&&QP(o)&&t.push(St("assignment/unusedSlot",{de:`${Nt(o)} wird hier nicht gebraucht \u2014 erlaubt, und nicht ausgewertet`,en:`${Nn(o)} is not needed here \u2014 allowed, and not evaluated`},{slot:o},"info"));return t}s(G2,"validateRules");function z2({slot:e,rules:n}){let t=[];return(n.length===0||n[n.length-1].when!==null)&&t.push(St("assignment/defaultRowMissing",{de:`${Nt(e)} muss mit einer Zeile ohne Bedingung enden (\u201Esonst\u201C)`,en:`${Nn(e)} must end with a row without condition ("otherwise")`},{slot:e})),n.forEach((r,i)=>{let o={slot:e,row:i},{when:a,assign:l}=r;if(a===null&&i<n.length-1&&t.push(St("assignment/ruleAfterDefault",{de:`${Nt(e,i)} hat keine Bedingung, aber es folgen Zeilen \u2014 sie treffen nie zu`,en:`${Nn(e,i)} has no condition, but rows follow it \u2014 they can never match`},o)),a!==null){let d=Qf(a,Js,[ji]);for(let c of d)t.push({...c,message:{de:`${c.message.de} (${Nt(e,i)})`,en:`${c.message.en} (${Nn(e,i)})`},...o});if(d.every(c=>c.severity!=="error")){KP(a)||t.push(St("assignment/shadowedRule",{de:`${Nt(e,i)} liest nichts aus dem Vorgang \u2014 sie gilt immer oder nie`,en:`${Nn(e,i)} reads nothing of the application \u2014 it holds for every application or for none`},o));let c=n.slice(0,i).findIndex(u=>u.when!==null&&MP(u.when,a));c!==-1&&t.push(St("assignment/shadowedRule",{de:`${Nt(e,i)} wiederholt die Bedingung von Zeile #${c+1} \u2014 sie trifft nie zu`,en:`${Nn(e,i)} repeats the condition of row #${c+1} \u2014 it can never match`},o))}}if(e===wn&&l.kind==="slot"&&t.push(St("assignment/slotForwardRef",{de:`${Nt(e,i)} \xFCbernimmt '${l.slot}' \u2014 das darf nur eine Team-Liste nach '${wn}'`,en:`${Nn(e,i)} copies '${l.slot}' \u2014 only a team slot after '${wn}' may`},o)),e===wn&&l.kind==="queue"&&t.push(St("assignment/queueOnProcessSlot",{de:`${Nt(e,i)} weist die Queue zu \u2014 die Prozesszust\xE4ndigkeit ist immer eine Person`,en:`${Nn(e,i)} assigns the queue \u2014 the responsible slot is always a person`},o)),l.kind==="unassigned"&&t.push(St("assignment/targetMissing",{de:`${Nt(e,i)} nennt noch niemanden \u2014 Person w\xE4hlen`,en:`${Nn(e,i)} names no one yet \u2014 choose a person`},o)),l.kind==="rotation"){let d=HP(l.configKeys);d!==null&&t.push(St("assignment/rotationPool",{de:`${Nt(e,i)}: die Reihum-Liste ${d.de}`,en:`${Nn(e,i)} rotates over a pool that ${d.en}`},o))}l.kind==="creator"&&(a===null||!LP(a,ji))&&t.push(St("assignment/unguardedTarget",{de:`${Nt(e,i)} weist die anlegende Person zu \u2014 die gibt es nur, wenn die Bedingung der Zeile '${ji}' ist (oder enth\xE4lt)`,en:`${Nn(e,i)} assigns the creator, which exists only when the row's condition is (or has the conjunct) '${ji}'`},o))}),t}s(z2,"rowIssues");function tN(e,n){for(let r of n)e.some(i=>i.slot===r)||F(`[assignment/slotMissing] ${Nn(r)} has no rule list`);let t=new Set(n);return e.filter(r=>t.has(r.slot))}s(tN,"selectSlots");function W2(e,n){return qP(tN(e,n).flatMap(t=>t.rules.flatMap(r=>r.when===null?[]:[r.when])))}s(W2,"contextKeysOfRules");function rN(e,n,t,r){Ws(Js);let i=tN(e,t),o=W2(e,t),a=Yf(Js.types,n,o);CP(Js,a,o);let l=[];for(let{slot:d,rules:c}of i){let u=c.findIndex((m,y)=>{if(m.when===null)return!0;for(let k of xn(gr(m.when)))Object.hasOwn(a,k)||F(`[condition/unknownIdentifier] ${Nn(d,y)} reads '${k}', which the context does not carry`);return VI(m.when,{values:a})});u===-1&&F(`[assignment/defaultRowMissing] ${Nn(d)}: no row matched and there is no default row`);let p=c[u].assign;l.push({slot:d,ruleIndex:u,assign:p,value:Y2(d,u,p,l,r)})}return l}s(rN,"evaluateRules");function Y2(e,n,t,r,i){switch(t.kind){case"person":return{kind:"value",value:i.person(t.configKey)};case"creator":return{kind:"value",value:i.creator()};case"rotation":return{kind:"value",value:i.rotation(t,{slot:e,row:n})};case"unassigned":return F(`[assignment/targetMissing] ${Nn(e,n)} names no one`);case"queue":return e===wn&&F(`[assignment/queueOnProcessSlot] ${Nn(e,n)} assigns the queue`),{kind:"queue"};case"slot":{let o=e===wn?void 0:r.find(a=>a.slot===t.slot);return o===void 0&&F(`[assignment/slotForwardRef] ${Nn(e,n)} copies '${t.slot}', which is not decided before it`),o.value}}}s(Y2,"resolveTarget");var gw={person:["kind","configKey"],creator:["kind"],slot:["kind","slot"],queue:["kind"],rotation:["kind","configKeys","mode"],unassigned:["kind"]};function H2(e){if(typeof e!="object"||e===null)return!1;let{kind:n,groupKey:t,...r}=e;return Object.keys(r).length>0?!1:n==="responsible"?t===void 0:n==="team"&&typeof t=="string"&&t.length>0}s(H2,"isStoredSlot");function iN(e){let n=[],t=s((r,i)=>n.push(`[assignment/shape] ${r}: ${i}`),"bad");return Array.isArray(e)?(e.forEach((r,i)=>{let o=`slots[${i}]`;if(typeof r!="object"||r===null)return t(o,"must be { slot, rules }");let{slot:a,rules:l,...d}=r;if(Object.keys(d).length>0&&t(o,`unknown field(s) ${Object.keys(d).join(", ")}`),H2(a)||t(o,"slot must be { kind: 'responsible' } or { kind: 'team', groupKey: '<team key>' }"),!Array.isArray(l))return t(o,"rules must be a list");l.forEach((c,u)=>{let p=`${o}.rules[${u}]`;if(typeof c!="object"||c===null)return t(p,"must be { when, assign }");let{when:m,assign:y,...k}=c;Object.keys(k).length>0&&t(p,`unknown field(s) ${Object.keys(k).join(", ")}`),m!==null&&typeof m!="string"&&t(p,"when must be a condition string or null (\u201Esonst\u201C)");let g=y?.kind;if(typeof y!="object"||y===null||typeof g!="string"||!Object.hasOwn(gw,g))return t(p,`assign must be one of ${Object.keys(gw).map(I=>`{kind:'${I}'}`).join(", ")}`);let v=gw[g],E=Object.keys(y);(E.some(I=>!v.includes(I))||v.some(I=>!E.includes(I)))&&t(p,`a '${g}' target has exactly the field(s) ${v.join(", ")}`);let A=y;if(g==="person"&&(typeof A.configKey!="string"||A.configKey.length===0)&&t(p,"a 'person' target needs a non-empty configKey"),g==="rotation"){let I=A.configKeys;(!Array.isArray(I)||I.some(_=>typeof _!="string"))&&t(p,"a 'rotation' target needs configKeys, a list of person keys"),hw.includes(A.mode)||t(p,`a 'rotation' target's mode is one of ${hw.map(_=>`'${_}'`).join(", ")}`)}g==="slot"&&A.slot!==wn&&t(p,`a 'slot' target copies '${wn}' and nothing else`)})}),n):(t("slots","must be a list of { slot, rules }"),n)}s(iN,"ruleShapeIssues");function oN(e){let n=e??{},t=[];if(n.teamOwnerBindings!==void 0&&t.push({de:"[assignment/legacyBindings] der Workflow tr\xE4gt noch teamOwnerBindings \u2014 die Zust\xE4ndigkeitsregel ersetzt sie; das Feld entfernen",en:"[assignment/legacyBindings] the workflow still carries teamOwnerBindings \u2014 the assignment rule replaces them; remove the field"}),n.assignmentRules===void 0)return t.push({de:"[assignment/noRules] der Workflow hat keine Zust\xE4ndigkeitsregel (graph.assignmentRules) \u2014 jeder Workflow muss sagen, wer zust\xE4ndig wird",en:"[assignment/noRules] the workflow has no assignment rule (graph.assignmentRules) \u2014 every workflow must say who becomes responsible"}),t;let r=iN(n.assignmentRules);if(r.length>0)return[...t,...r.map(o=>({de:o,en:o}))];let i=Zf({nodes:Array.isArray(n.nodes)?n.nodes:[]});for(let o of G2(ZP(n.assignmentRules),i))o.severity==="error"&&t.push(o.message);return t}s(oN,"workflowAssignmentIssues");function Xf(e,n){let o=new Map;for(let d of e)o.set(d,0);let a=new Map,l=[];for(let d of e){if((o.get(d)??0)!==0)continue;let c=[{id:d,edges:n(d),idx:0}];for(o.set(d,1),a.set(d,null);c.length>0;){let u=c[c.length-1];if(u.idx>=u.edges.length){o.set(u.id,2),c.pop();continue}let{target:p,edge:m}=u.edges[u.idx];u.idx++;let y=o.get(p)??0;if(y===1){let k=[p],g=u.id;for(;g&&g!==p;)k.push(g),g=a.get(g)??null;k.reverse(),l.push({edge:m,source:u.id,target:p,cycle:k})}else y===0&&(o.set(p,1),a.set(p,u.id),c.push({id:p,edges:n(p),idx:0}))}}return l}s(Xf,"detectBackEdges");var yw="team:",J2=/^[a-z0-9][a-z0-9-]*$/;function Q2(e){if(!e.startsWith(yw))return null;let n=e.slice(yw.length);return n.length>0?n:null}s(Q2,"teamKeyOfMember");function ep(e){return`${yw}${e}`}s(ep,"teamMember");function Qs(e){let n=e.channels;return n===void 0?[]:(Array.isArray(n)||F("graph.channels must be an array"),n)}s(Qs,"readAuthoredChannels");function sN(e){return[...Ll(e)].sort()}s(sN,"derivedChannelTeamKeys");function aN(e,n){let t=e.toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"channel";if(!n.has(t))return t;for(let r=2;;r++){let i=`${t}-${r}`;if(!n.has(i))return i}}s(aN,"mintChannelKey");function lN(e,n){let t=e.channels;if(t===void 0)return[];if(!Array.isArray(t))return[{path:"channels",reason:{de:"[channels/shape] graph.channels muss eine Liste sein.",en:"[channels/shape] graph.channels must be a list."}}];let r=[],i=Ll(e),o=new Set,a=new Map;return t.forEach((l,d)=>{let c=`channels[${d}]`,u=l;if(u===null||typeof u!="object"||typeof u.key!="string"||Rn(u.label)==="not-localized"||!Array.isArray(u.members)||!u.members.every(E=>typeof E=="string")){r.push({path:c,reason:{de:"[channels/shape] Ein Kanal braucht key, label ({ de, en }) und members (Liste von Texten).",en:"[channels/shape] A channel needs key, label ({ de, en }) and members (a list of texts)."}});return}let p={de:`Kanal "${u.key}"`,en:`Channel "${u.key}"`};J2.test(u.key)||r.push({path:`${c}.key`,reason:{de:`[channels/invalidKey] ${p.de}: Schl\xFCssel nur aus Kleinbuchstaben, Ziffern und Bindestrich.`,en:`[channels/invalidKey] ${p.en}: key only from lowercase letters, digits and hyphens.`}}),o.has(u.key)&&r.push({path:`${c}.key`,reason:{de:`[channels/duplicateKey] ${p.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[channels/duplicateKey] ${p.en}: key is used twice.`}}),o.add(u.key);let m=Rn(u.label);if(m!=="not-localized"&&m.length===2?r.push({path:`${c}.label`,reason:{de:`[channels/emptyLabel] ${p.de}: Bezeichnung fehlt.`,en:`[channels/emptyLabel] ${p.en}: name is missing.`}}):m!=="not-localized"&&m.length>0&&r.push({path:`${c}.label`,reason:{de:`[i18n/missingTranslation] ${p.de}: Bezeichnung fehlt in: ${m.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${p.en}: name is missing in: ${m.join(", ")} \u2014 every displayed text needs German and English.`}}),u.members.length===0){r.push({path:`${c}.members`,reason:{de:`[channels/emptyMembers] ${p.de}: mindestens ein Team.`,en:`[channels/emptyMembers] ${p.en}: at least one team.`}});return}let y=[];for(let E of u.members){let A=Q2(E);if(A===null){r.push({path:`${c}.members`,reason:{de:`[channels/invalidMember] ${p.de}: "${E}" ist kein "team:<schl\xFCssel>".`,en:`[channels/invalidMember] ${p.en}: "${E}" is not a "team:<key>".`}});continue}if(y.includes(A)){r.push({path:`${c}.members`,reason:{de:`[channels/duplicateMember] ${p.de}: Team "${A}" ist doppelt genannt.`,en:`[channels/duplicateMember] ${p.en}: team "${A}" is named twice.`}});continue}n!==void 0&&!n.has(A)&&r.push({path:`${c}.members`,reason:{de:`[channels/unknownTeam] ${p.de}: Team "${A}" gibt es in diesem Mandanten nicht (oder es ist die Bewerbergruppe).`,en:`[channels/unknownTeam] ${p.en}: team "${A}" does not exist at this school (or it is the applicant group).`}}),y.push(A)}if(y.length===0)return;let k=[...y].sort().join("+"),[g]=y;y.length===1&&g!==void 0&&i.has(g)&&r.push({path:`${c}.members`,reason:{de:`[channels/duplicatesDerived] ${p.de}: Team "${g}" ist am Prozess beteiligt und hat seinen Kanal schon automatisch.`,en:`[channels/duplicatesDerived] ${p.en}: team "${g}" takes part in the process and already has its channel automatically.`}});let v=a.get(k);v!==void 0?r.push({path:`${c}.members`,reason:{de:`[channels/duplicateMembership] ${p.de}: dieselben Teams wie Kanal "${v}" \u2014 zwei Tabs w\xE4ren derselbe Chat.`,en:`[channels/duplicateMembership] ${p.en}: the same teams as channel "${v}" \u2014 two tabs would be the same chat.`}}):a.set(k,u.key)}),r}s(lN,"channelIssues");var _pe=Object.freeze({});function Z2(e,n){return Object.freeze(Yf(Xr,e,n))}s(Z2,"formContextEntries");function dN(e){return e.env??[]}s(dN,"declaredContextKeys");function cN(e,n){return dN(e).every(t=>uN(t,n?.[t]))}s(cN,"scenarioContextComplete");function uN(e,n){return _P(Xr,e,n)}s(uN,"contextValueComplete");function fN(e,n){return Z2(n??{},dN(e))}s(fN,"scenarioContextEntries");function kw(e){return Cl(e)}s(kw,"isContextIdentifier");function X2(e,n,t){let r=Wf(Xr,e);if(r!==null)return{severity:"error",path:t,code:"env/unknownKey",message:r.message};let[,i=""]=e.split(".");return n.has(i)?null:{severity:"error",path:t,code:"env/undeclared",message:{de:`'${e}' liest den Umgebungsschl\xFCssel '${i}', den das Formular nicht in \`env\` deklariert.`,en:`'${e}' reads the environment key '${i}', which the form does not declare in \`env\`.`}}}s(X2,"contextIdentifierIssue");var ww=sf("stage.key");function eY(e){let n=[],t=s(i=>i.kind==="ident"&&i.path===ww,"isStageKey"),r=s(i=>{switch(i.kind){case"binary":if((i.op==="=="||i.op==="!=")&&(t(i.left)&&i.right.kind==="str"&&n.push(i.right.value),t(i.right)&&i.left.kind==="str"&&n.push(i.left.value)),i.op==="in"&&t(i.left)&&i.right.kind==="arr")for(let o of i.right.items)o.kind==="str"&&n.push(o.value);r(i.left),r(i.right);return;case"unary":r(i.operand);return;case"if":r(i.cond),r(i.then),r(i.else);return;case"call":i.args.forEach(r);return;case"arr":i.items.forEach(r);return;default:return}},"walk");return r(e),n}s(eY,"stageKeyLiterals");function np(e,n,t){return n===void 0?[]:eY(e).filter(r=>!n.has(r)).map(r=>mN(r,n,t))}s(np,"stageKeyAstIssues");function pN(e,n){if(n===void 0)return[];let t=[];for(let r of e.testScenarios??[]){let i=r.env?.stage;typeof i?.key=="string"&&!n.has(i.key)&&t.push(mN(i.key,n,`scenario:${r.id}/env`))}return t}s(pN,"scenarioStageKeyIssues");function mN(e,n,t){let r=[...n].sort();return{severity:"error",path:t,code:"env/unknownStageKey",message:{de:`'${e}' ist kein Stufenschl\xFCssel des Programms dieses Angebots \u2014 `+(r.length>0?`bekannt: ${r.join(", ")}.`:"das Angebot hat kein Programm mit Stufen.")+` \`${ww}\` ist der Bundle-Schl\xFCssel (\`program.stages[].key\`), nie das gespeicherte \`<program>-stufe-<key>\`.`,en:`'${e}' is not a stage key of the offer's program \u2014 `+(r.length>0?`known: ${r.join(", ")}.`:"the offer has no program with stages.")+` \`${ww}\` is the bundle key (\`program.stages[].key\`), never the stored \`<program>-stufe-<key>\`.`}}}s(mN,"unknownStageKeyIssue");function hN(e,n,t){let r=[];for(let i of xn(e)){if(!kw(i))continue;let o=X2(i,n,t);o!==null&&r.push(o)}if(r.length>0)return r;for(let{identifier:i,op:o}of pw(e,rf))r.push({severity:"error",path:t,code:"env/unguardedNullable",message:{de:`'${o}' \xFCber '${i}', das bei manchen Bewerbungen leer ist, braucht davor eine Absicherung '${i} != null &&' \u2014 lege fest, was ein leerer Wert bedeutet.`,en:`'${o}' over '${i}', which is empty for some applications, needs a guard '${i} != null &&' before it \u2014 say what an empty value means.`}});return r}s(hN,"contextAstIssues");function gN(e,n){let t=[...nY(e)],r=new Set(e.env??[]);for(let i of e.env??[]){if(!ws(i)){t.push({severity:"error",path:"env",code:"env/unknownKey",message:{de:`Der deklarierte Umgebungsschl\xFCssel '${i}' geh\xF6rt nicht zum Vokabular (${ys.join(", ")}).`,en:`Declared environment key '${i}' is not in the vocabulary (${ys.join(", ")}).`}});continue}n!==void 0&&!n.has(i)&&t.push({severity:"error",path:"env",code:"env/unsupplied",message:{de:`Das Formular deklariert den Umgebungsschl\xFCssel '${i}', aber sein Host liefert ihn nicht.`,en:`The form declares environment key '${i}', but its host does not supply it.`}})}for(let i of e.testScenarios??[]){let o=[...r].filter(a=>ws(a)&&!uN(a,i.env?.[a]));o.length>0&&t.push({severity:"error",path:`scenario:${i.id}/env`,code:"env/unsampled",message:{de:`Szenario '${i.id}' belegt den deklarierten Umgebungsschl\xFCssel ${o.map(a=>`'${a}'`).join(", ")} nicht vollst\xE4ndig \u2014 eine echte Bewerbung tr\xE4gt immer jedes seiner Felder (ein leeres als null).`,en:`Scenario '${i.id}' does not sample the declared environment key(s) ${o.map(a=>`'${a}'`).join(", ")} completely \u2014 a real application always carries every field of them (an empty one as null).`}});for(let a of Object.keys(i.env??{}))ws(a)?r.has(a)||t.push({severity:"error",path:`scenario:${i.id}/env`,code:"env/undeclared",message:{de:`Szenario '${i.id}' belegt den Umgebungsschl\xFCssel '${a}', den das Formular nicht deklariert.`,en:`Scenario '${i.id}' samples environment key '${a}', which the form does not declare.`}}):t.push({severity:"error",path:`scenario:${i.id}/env`,code:"env/unknownKey",message:{de:`Szenario '${i.id}' belegt den unbekannten Umgebungsschl\xFCssel '${a}'.`,en:`Scenario '${i.id}' samples unknown environment key '${a}'.`}})}return t}s(gN,"formContextIssues");function nY(e){let n=[];Object.hasOwn(e,"context")&&n.push({severity:"error",path:"context",code:"env/retiredField",message:{de:"`context` ist abgeschafft \u2014 ein Formular deklariert die gelesene Umgebung als `env`.",en:"`context` is retired \u2014 a form declares the environment it reads as `env`."}});let t=e.testScenarios;for(let r of Array.isArray(t)?t:[])r!==null&&typeof r=="object"&&Object.hasOwn(r,"context")&&n.push({severity:"error",path:`scenario:${String(r.id)}/context`,code:"env/retiredField",message:{de:"`context` ist abgeschafft \u2014 ein Szenario belegt die Umgebung als `env`.",en:"`context` is retired \u2014 a scenario samples the environment as `env`."}});return n}s(nY,"retiredContextFields");function tp(e,n,t){let r=Qf(e,n).filter(o=>o.severity==="error").map(o=>o.message);if(r.length>0)return r;let i=[];if(t?.liveEnvKeys!==void 0)for(let o of fw(e,n)){let a=YP(o.path,t.liveEnvKeys);a===null&&F(`[condition] no live-key universe for '${o.path}' \u2014 extend liveKeyUniverse`),a.has(o.value)||i.push({de:`$env.${o.path} == '${o.value}' nennt keinen Schl\xFCssel dieses Mandanten.`,en:`$env.${o.path} == '${o.value}' names no key of this school.`})}for(let o of np(In(e),t?.stageKeys,""))i.push({de:`[${o.code}] ${o.message.de}`,en:`[${o.code}] ${o.message.en}`});return i}s(tp,"envConditionFindings");function rp(e){return e.kind==="entered"&&!e.repeated&&e.reviewRequired}s(rp,"isReviewField");function Zs(e){let n=[],t=[];function r(g,v){try{return In(g)}catch(E){n.push({path:v,src:g,reason:E instanceof Error?E.message:String(E)});return}}s(r,"tryParse");function i(g,v){return{...g,visibleIf:g.visibleIf?r(g.visibleIf,`${v}.visibleIf`):void 0,requiredIf:g.requiredIf?r(g.requiredIf,`${v}.requiredIf`):void 0,disabledIf:g.disabledIf?r(g.disabledIf,`${v}.disabledIf`):void 0,defaultValue:g.defaultValue?r(g.defaultValue,`${v}.defaultValue`):void 0}}s(i,"compileField");function o(g,v){return{...g,visibleIf:g.visibleIf?r(g.visibleIf,`${v}.visibleIf`):void 0,fields:g.fields.map((E,A)=>i(E,`${v}.fields[${A}]`))}}s(o,"compileGroup");function a(g,v){return{...g,itemTemplate:g.itemTemplate.map((E,A)=>i(E,`${v}.itemTemplate[${A}]`)),effects:g.effects?.map((E,A)=>d(E,`${v}.effects[${A}]`)),itemVisibleIf:g.itemVisibleIf?r(g.itemVisibleIf,`${v}.itemVisibleIf`):void 0}}s(a,"compileRepeated");function l(g,v){let E=[];return g.fields.forEach((A,I)=>{if(A.externalFlag){t.push({key:A.key,label:A.label,defaultValue:A.defaultValue?r(A.defaultValue,`${v}.fields[${I}].defaultValue`):void 0});return}E.push(i(A,`${v}.fields[${I}]`))}),{...g,visibleIf:g.visibleIf?r(g.visibleIf,`${v}.visibleIf`):void 0,fields:E,groups:g.groups?.map((A,I)=>o(A,`${v}.groups[${I}]`)),computed:g.computed?.map((A,I)=>{let _=r(A.expression,`${v}.computed[${I}].expression`);return{key:A.key,expression:_??{kind:"null"}}}),subsections:g.subsections?.map((A,I)=>l(A,`${v}.subsections[${I}]`)),repeated:g.repeated?.map((A,I)=>a(A,`${v}.repeated[${I}]`)),validators:g.validators}}s(l,"compileSection");function d(g,v){return{...g,when:g.when?r(g.when,`${v}.when`):void 0}}s(d,"compileEffect");function c(g,v){let E=r(g.when,`${v}.when`);return E?{...g,when:E}:null}s(c,"compileOutcome");let u=e.sections.map((g,v)=>l(g,`sections[${v}]`)),p=(e.effects??[]).map((g,v)=>d(g,`effects[${v}]`)),m=[],y=e.outcomes??[];for(let g=0;g<y.length;g++){let v=y[g],E=c(v,`outcomes[${g}]`);E&&m.push(E)}return{compiled:{...e,sections:u,effects:p,outcomes:m,flags:t},errors:n}}s(Zs,"compileForm");var tY=new Set(["decision","review","governedDocument"]);function wN(e){return tY.has(e.type)&&!(e.type==="governedDocument"&&e.production==="none")}s(wN,"isReadinessGatedNode");function rY(e){let n=new Map,t=oY(e),r=s((i,o)=>{let a=bw(o),l=[...i.fields,...(i.groups??[]).flatMap(d=>d.fields)];for(let d of l)d.externalFlag!==!0&&n.set(d.key,{kind:"entered",key:d.key,label:d.label,qualifier:iY(d.bucket,t,a),section:a,type:d.type,enumSource:yN(d),repeated:!1,reviewRequired:d.reviewRequired===!0});for(let d of i.repeated??[])for(let c of d.itemTemplate){let u=`${d.key}.${c.key}`;n.set(u,{kind:"entered",key:u,label:c.label,qualifier:bw(d),section:a,type:c.type,enumSource:yN(c),repeated:!0,reviewRequired:!1})}for(let d of i.computed??[]){let c=xn(In(d.expression));n.set(d.key,{kind:"computed",key:d.key,label:d.label??{de:d.key,en:d.key},qualifier:a,deps:c})}for(let d of i.subsections??[])r(d,o)},"visit");for(let i of e.sections)r(i,i);return n}s(rY,"formFieldCatalog");function yN(e){return e.type==="enum"?e:null}s(yN,"enumSourceOf");function iY(e,n,t){return e===void 0?t:n.get(e)??t}s(iY,"fieldQualifier");function oY(e){let n=new Map,t=s((r,i)=>{i===void 0||n.has(r)||n.set(r,bw(i))},"add");for(let r of bN(e))r.kind==="person"?t(r.bucket,r.display):r.kind==="organization"&&t(r.id.replace(/^o\./,""),r.display);return n}s(oY,"bucketWordings");function kN(e){return e.flatMap(n=>[n,...kN(n.subsections??[])])}s(kN,"allSections");function bN(e){return[...e.effects,...kN(e.sections).flatMap(n=>(n.repeated??[]).flatMap(t=>t.effects??[]))]}s(bN,"allEffects");function bw(e){return{label:e.label}}s(bw,"wordingOf");function vN(e){return vl(e).flatMap(({slot:n,address:t})=>{let r=XI(t);return r===null||bl.includes(r.path)?[]:[{slotId:n,owner:r.owner,fieldKey:r.path}]})}s(vN,"admissionBindingLeaves");function sY(e,n){let t=e.get(n);if(t===void 0)return null;let r=[],i=new Set,o=s(a=>{if(!i.has(a.key)&&(i.add(a.key),r.push({fieldKey:a.key,kind:a.kind}),a.kind==="computed"))for(let l of a.deps){let d=e.get(l);d!==void 0&&o(d)}},"walk");return o(t),r}s(sY,"expandKey");function aY(e){let n=new Set;for(let t of bN(e))if(!(t.kind!=="person"||t.contractParty===void 0)&&t.when!==void 0)for(let r of xn(In(t.when)))n.add(r);return[...n]}s(aY,"contractPartyConditionKeys");function lY(e){return Zs(e).compiled.flags.map(n=>({key:n.key,name:n.label}))}s(lY,"formExternalFlags");function xN(e){return{readinessFormFieldsByFormNode:new Map([...e].map(([n,t])=>[n,rY(t)])),readinessPartyConditionKeysByFormNode:new Map([...e].map(([n,t])=>[n,new Set(aY(t))])),formFlagKeysByFormNode:new Map([...e].map(([n,t])=>[n,new Set(lY(t).map(r=>r.key))])),formViewKeysByFormNode:new Map([...e].map(([n,t])=>[n,new Set((t.views??[]).map(r=>r.key))]))}}s(xN,"readinessUniverse");function vw(e,n){let t=new Set;for(let r of n)for(let i of sY(e,r)??[])i.kind==="entered"&&t.add(i.fieldKey);return t}s(vw,"enteredFieldsBehind");var dY=new Set(["label","sublabel","title","description","body","chipLabel","nextAction","confirmLabel","placeholder","helpText","subject","heading","hint","notice","reason"]);function cY(e){return dY.has(e)?!0:SN(e)?!1:/(Label|Title|Body|Description|Text|Hint|Heading|Placeholder)$/.test(e)}s(cY,"isTextKey");function SN(e){return/^localized[A-Z]/.test(e)}s(SN,"isLegacyTwinKey");var uY=new Set(["titles","responseLabels","outputLabels","enumOptionLabels"]),fY=new Set(["inputs","resolver","library"]);function op(e,n){let t=[];return xw(e,n,t),t}s(op,"findUnlocalizedTexts");function xw(e,n,t){if(Array.isArray(e)){e.forEach((i,o)=>xw(i,`${n}[${mY(i,o)}]`,t));return}if(e===null||typeof e!="object")return;let r=e;for(let[i,o]of Object.entries(r)){let a=`${n}.${i}`;if(!fY.has(i)){if(SN(i)){t.push({path:a,missing:"legacy-twin"});continue}if(cY(i)){pY(o,a,t);continue}if(uY.has(i)&&o!==null&&typeof o=="object"){for(let[l,d]of Object.entries(o))d!==void 0&&AN(d,`${a}.${l}`,t);continue}xw(o,a,t)}}}s(xw,"walk");function pY(e,n,t){e!=null&&AN(e,n,t)}s(pY,"checkText");function AN(e,n,t){let r=Rn(e);(r==="not-localized"||r.length>0)&&t.push({path:n,missing:r})}s(AN,"report");function mY(e,n){if(e!==null&&typeof e=="object"){let t=e;if(typeof t.id=="string")return t.id;if(typeof t.key=="string")return t.key}return String(n)}s(mY,"keyOf");function ip(e,n){return e==="not-localized"?n==="de"?"ist kein zweisprachiger Text ({ de, en })":"is not a bilingual text ({ de, en })":e==="legacy-twin"?n==="de"?'ist ein Zwilling der alten Form \u2014 der Text geh\xF6rt in das Feld ohne \u201Elocalized"':'is a twin of the old shape \u2014 the text belongs in the field without "localized"':n==="de"?`fehlt in: ${e.join(", ")}`:`is missing in: ${e.join(", ")}`}s(ip,"describe");function Sw({path:e,missing:n}){return n==="legacy-twin"?{de:`[i18n/legacyTwin] ${e} ${ip(n,"de")}.`,en:`[i18n/legacyTwin] ${e} ${ip(n,"en")}.`}:{de:`[i18n/missingTranslation] ${e} ${ip(n,"de")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch; die Sprache folgt dem Konto des Lesenden.`,en:`[i18n/missingTranslation] ${e} ${ip(n,"en")} \u2014 every displayed text needs German and English; the language follows the reader's account.`}}s(Sw,"unlocalizedTextReason");var hY={engagePush:["engage"]};function gY(e){let n=hY[e.type];return n===void 0?e:Object.fromEntries(Object.entries(e).filter(([t])=>!n.includes(t)))}s(gY,"withoutMachineData");function EN(e,n){return[...op(e.nodes.map(gY),"nodes"),...n===void 0?[]:op(n,`layout.${n.id}`)].map(r=>({layer:"GRAPH",kind:"i18n",path:r.path,reason:Sw(r),severity:"error"}))}s(EN,"checkLocalizedTexts");var Ao=5,Eo=480;function Mr(e){return typeof e=="string"&&e.trim().length>0}s(Mr,"isNonEmptyString");function $N(e,n,t){return Object.keys(e).filter(r=>!n.includes(r)).map(r=>({field:`result.${r}`,code:Ze.unknownField,message:{de:`Unbekanntes Feld '${r}' im ${t.de}; erlaubt sind: ${n.join(", ")}.`,en:`Unknown field '${r}' in the ${t.en}; allowed: ${n.join(", ")}.`}}))}s($N,"unknownFieldIssues");function yY(e){let n=[],t=e.title;(t===void 0||typeof t!="object"||t===null||!Mr(t.de)||!Mr(t.en))&&n.push({field:"result.title",code:Ze.appointmentMissingTitle,message:{de:"Ein Termin-Ergebnis braucht einen neutralen Titel in beiden Sprachen ({ de, en }) \u2014 er steht in der Mail und in der Kalenderdatei der Familie, deshalb nie ein Familienname.",en:"An appointment result needs a neutral title in both languages ({ de, en }) \u2014 it appears in the email and in the family's calendar file, so never a family name."}});let r=e.durationMinutes;return(typeof r!="number"||!Number.isInteger(r)||r<Ao||r>Eo)&&n.push({field:"result.durationMinutes",code:Ze.appointmentInvalidDuration,message:{de:`'durationMinutes' muss eine ganze Zahl von ${Ao} bis ${Eo} sein, erhalten ${JSON.stringify(r)}.`,en:`'durationMinutes' must be a whole number from ${Ao} to ${Eo}, got ${JSON.stringify(r)}.`}}),n.push(...$N(e,["kind","title","durationMinutes"],{de:"Termin-Ergebnis",en:"appointment result"})),n}s(yY,"appointmentIssues");function TN(e){if(typeof e!="object"||e===null)return!1;let n=e;return Mr(n.de)&&Mr(n.en)}s(TN,"isBilingual");var Aw=["key","type","label","writes","options","min","suggest","evidence","evidenceFrom"];function wY(e){let n=s((i,o)=>({field:i,code:Ze.recordFields,message:o}),"issue");if(!Array.isArray(e)||e.length===0)return[n("result.fields",{de:"Eine Erfassung braucht mindestens ein Feld ('result.fields').",en:"A record needs at least one field ('result.fields')."})];let t=[],r=new Set;for(let[i,o]of e.entries()){let a=`result.fields[${i}]`;if(typeof o!="object"||o===null||Array.isArray(o)){t.push(n(a,{de:"Ein Feld der Erfassung muss ein Objekt sein.",en:"A field of the record must be an object."}));continue}let l=o,d=l.key;typeof d!="string"||!/^[a-z][a-zA-Z0-9_]*$/.test(d)?t.push(n(`${a}.key`,{de:`Feld-Schl\xFCssel ${JSON.stringify(d)} \u2014 erlaubt sind Buchstaben, Ziffern und _, beginnend mit einem Kleinbuchstaben.`,en:`Field key ${JSON.stringify(d)} \u2014 letters, digits and _ are allowed, starting with a lowercase letter.`})):r.has(d)?t.push(n(`${a}.key`,{de:`Feld-Schl\xFCssel "${d}" ist doppelt.`,en:`Field key "${d}" is duplicated.`})):r.add(d);let c=typeof d=="string"?`"${d}"`:`Nr. ${i+1}`,u=typeof d=="string"?`"${d}"`:`no. ${i+1}`;if(hy(l.type)||t.push(n(`${a}.type`,{de:`Feld ${c}: Typ ${JSON.stringify(l.type)} \u2014 erlaubt: ${hf.join(", ")}.`,en:`Field ${u}: type ${JSON.stringify(l.type)} \u2014 allowed: ${hf.join(", ")}.`})),TN(l.label)||t.push(n(`${a}.label`,{de:`Feld ${c} braucht ein Label in beiden Sprachen ({ de, en }).`,en:`Field ${u} needs a label in both languages ({ de, en }).`})),Mr(l.writes)||t.push(n(`${a}.writes`,{de:`Feld ${c} schreibt in keinen Vorgangs-Schl\xFCssel ('writes') \u2014 ein Wert, den niemand lesen kann, geh\xF6rt nicht in eine Erfassung.`,en:`Field ${u} writes to no process key ('writes') \u2014 a value nobody can read does not belong in a record.`})),l.type==="enum"){let m=Array.isArray(l.options)?l.options:[],y=m.map(k=>k.key);(m.length<2||y.some(k=>typeof k!="string"||k.length===0)||new Set(y).size!==y.length||m.some(k=>!TN(k.label)))&&t.push(n(`${a}.options`,{de:`Feld ${c} (Auswahl) braucht mindestens 2 Optionen mit eindeutigen Schl\xFCsseln und Labels in beiden Sprachen.`,en:`Field ${u} (choice) needs at least 2 options with unique keys and labels in both languages.`}))}else l.options!==void 0&&t.push(n(`${a}.options`,{de:`Feld ${c}: 'options' gibt es nur bei Typ 'enum'.`,en:`Field ${u}: 'options' exists only for type 'enum'.`}));if(l.min!==void 0&&(l.type!=="number"||typeof l.min!="number"||!Number.isInteger(l.min))&&t.push(n(`${a}.min`,{de:`Feld ${c}: 'min' gibt es nur bei Typ 'number', als ganze Zahl.`,en:`Field ${u}: 'min' exists only for type 'number', as a whole number.`})),l.evidence!==void 0&&typeof l.evidence!="boolean"&&t.push(n(`${a}.evidence`,{de:`Feld ${c}: 'evidence' ist true oder false.`,en:`Field ${u}: 'evidence' is true or false.`})),l.evidenceFrom!==void 0){let m=typeof l.min=="number"?l.min:0;(l.type!=="number"||l.evidence!==!0||typeof l.evidenceFrom!="number"||!Number.isInteger(l.evidenceFrom)||l.evidenceFrom<=m)&&t.push(n(`${a}.evidenceFrom`,{de:`Feld ${c}: 'evidenceFrom' gibt es nur bei Typ 'number' mit 'evidence', als ganze Zahl \xFCber dem Minimum (${m}) \u2014 sonst g\xE4lte der Nachweis immer.`,en:`Field ${u}: 'evidenceFrom' exists only for type 'number' with 'evidence', as a whole number above the minimum (${m}) \u2014 otherwise the proof would always apply.`}))}if(l.suggest!==void 0){let m=l.suggest,y=typeof m=="object"&&m!==null?m.kind:void 0;y==="form"&&"address"in m&&Object.keys(m).length===2&&(!we(m.address)||fn(m.address))||y==="siblingRank"&&Object.keys(m).length===1&&l.type==="number"||t.push({field:`${a}.suggest`,code:Ze.recordSuggest,message:{de:`Feld ${c}: Vorschlag ${JSON.stringify(l.suggest)} \u2014 erlaubt: { kind: 'form', address: '$node.<formular>.admission.<export>' } oder { kind: 'siblingRank' } (nur bei Typ 'number'); bekannte Arten: ${gy.join(", ")}.`,en:`Field ${u}: suggestion ${JSON.stringify(l.suggest)} \u2014 allowed: { kind: 'form', address: '$node.<form>.admission.<export>' } or { kind: 'siblingRank' } (only for type 'number'); known kinds: ${gy.join(", ")}.`}})}let p=Object.keys(l).filter(m=>!Aw.includes(m));p.length>0&&t.push(n(a,{de:`Feld ${c}: unbekannte Angabe ${p.map(m=>`'${m}'`).join(", ")}; erlaubt: ${Aw.join(", ")}.`,en:`Field ${u}: unknown entry ${p.map(m=>`'${m}'`).join(", ")}; allowed: ${Aw.join(", ")}.`}))}return t}s(wY,"recordFieldIssues");function kY(e,n,t){let r=[],i=n.options;if(e==="choice"){let o=Array.isArray(i)?i:[],a=o.map(l=>l.key);(o.length<2||a.some(l=>typeof l!="string"||l.length===0)||new Set(a).size!==a.length)&&r.push({field:"result.options",code:Ze.choiceOptions,message:{de:`Ein Auswahl-Ergebnis braucht mindestens 2 Optionen mit eindeutigen Schl\xFCsseln, erhalten ${JSON.stringify(a)}.`,en:`A choice result needs at least 2 options with unique keys, got ${JSON.stringify(a)}.`}})}else i!==void 0&&r.push({field:"result.options",code:Ze.choiceOptions,message:{de:`'result.options' gibt es nur bei 'choice' \u2014 ${e==="recommendation"?"eine Empfehlung hat die festen Tendenzen Positiv/Neutral/Negativ":"ein Freitext hat keine Auswahl"}.`,en:`'result.options' exists only for 'choice' \u2014 ${e==="recommendation"?"a recommendation has the fixed leanings Positive/Neutral/Negative":"a free text has no choice"}.`}});if(e==="pricedItem"){let o=n.item;if(!Mr(o))r.push({field:"result.item",code:Ze.pricedItemMissingItem,message:{de:"Ein Preispositions-Ergebnis nennt den Artikel, den es bepreist \u2014 'result.item' (der Schl\xFCssel des Artikels, z. B. 'tuition') fehlt.",en:"A priced-item result names the article it prices \u2014 'result.item' (the article's key, e.g. 'tuition') is missing."}});else if(t.billingItemKeys!==void 0&&!t.billingItemKeys.has(o))r.push({field:"result.item",code:Ze.pricedItemUnknownItem,message:{de:`'result.item' "${o}" \u2014 kein Artikel dieses Mandanten tr\xE4gt diesen Schl\xFCssel (bekannt: ${[...t.billingItemKeys].join(", ")||"keine"}).`,en:`'result.item' "${o}" \u2014 no article of this school has this key (known: ${[...t.billingItemKeys].join(", ")||"none"}).`}});else if(t.offerProgram===null)r.push({field:"result.item",code:Ze.pricedItemOfferWithoutProgram,message:{de:`'result.item' "${o}" \u2014 das Angebot ist keinem Programm zugeordnet, also geh\xF6rt kein Artikel zu ihm; dem Angebot ein Programm geben.`,en:`'result.item' "${o}" \u2014 the offer is not assigned to a program, so no article belongs to it; give the offer a program.`}});else if(t.offerProgram!==void 0&&!t.offerProgram.billingItemKeys.has(o)){let l=t.offerProgram;r.push({field:"result.item",code:Ze.pricedItemNotInProgram,message:{de:`'result.item' "${o}" \u2014 der Artikel ist dem Programm \u201E${l.nameDe}\u201C des Angebots nicht zugeordnet (zugeordnet: ${[...l.billingItemKeys].join(", ")||"keine"}); unter Finanzen \u2192 Artikel zuordnen, direkt oder \xFCber ein Paket.`,en:`'result.item' "${o}" \u2014 the article is not assigned to the offer's program "${l.nameDe}" (assigned: ${[...l.billingItemKeys].join(", ")||"none"}); assign it under Finance \u2192 articles, directly or through a package.`}})}let a=n.label;(typeof a!="object"||a===null||!Mr(a.de)||!Mr(a.en))&&r.push({field:"result.label",code:Ze.labelMissing,message:{de:"Ein Preispositions-Ergebnis braucht einen Namen f\xFCr seinen Wert in beiden Sprachen ('result.label', z. B. { de: 'Schulgeld mit Erm\xE4\xDFigung', en: 'Tuition after reduction' }) \u2014 so hei\xDFt er im Workflow und in der Verdrahtung.",en:"A priced-item result needs a name for its value in both languages ('result.label', e.g. { de: 'Schulgeld mit Erm\xE4\xDFigung', en: 'Tuition after reduction' }) \u2014 that is what it is called in the workflow and in the wiring."}})}else n.item!==void 0&&r.push({field:"result.item",code:Ze.itemOnNonPricedItem,message:{de:`'result.item' gibt es nur bei 'pricedItem' \u2014 ein ${e}-Ergebnis bepreist keinen Artikel.`,en:`'result.item' exists only for 'pricedItem' \u2014 a ${e} result prices no article.`}});if(e==="record"?(r.push(...wY(n.fields)),n.writes!==void 0&&r.push({field:"result.writes",code:Ze.writesOnProse,message:{de:"Eine Erfassung schreibt je Feld ('fields[].writes'), nie als Ganzes ('result.writes').",en:"A record writes per field ('fields[].writes'), never as a whole ('result.writes')."}}),n.label!==void 0&&r.push({field:"result.label",code:Ze.unknownField,message:{de:"Eine Erfassung benennt ihre Werte je Feld ('fields[].label'), nicht als Ganzes ('result.label').",en:"A record names its values per field ('fields[].label'), not as a whole ('result.label')."}})):n.fields!==void 0&&r.push({field:"result.fields",code:Ze.fieldsOnNonRecord,message:{de:`'result.fields' gibt es nur bei 'record' \u2014 ein ${e}-Ergebnis hat keine Felder.`,en:`'result.fields' exists only for 'record' \u2014 a ${e} result has no fields.`}}),e==="reduction"?(Mr(n.writes)||r.push({field:"result.writes",code:Ze.reductionPrices,message:{de:"Eine Reduktion schreibt ihren Betrag in einen Vorgangs-Schl\xFCssel vom Typ reduction ('result.writes') \u2014 sonst l\xE4se ihn kein Preis.",en:"A reduction writes its amount to a process key of type reduction ('result.writes') \u2014 otherwise no price would read it."}}),Mr(n.prices)||r.push({field:"result.prices",code:Ze.reductionPrices,message:{de:"Eine Reduktion nennt den abgeleiteten Preis, den sie senkt ('result.prices') \u2014 gegen seine Untergrenze wird der Betrag bei der Eingabe gepr\xFCft.",en:"A reduction names the derived price it lowers ('result.prices') \u2014 the amount is checked against its lower bound on entry."}})):n.prices!==void 0&&r.push({field:"result.prices",code:Ze.pricesOnNonReduction,message:{de:`'result.prices' gibt es nur bei 'reduction' \u2014 ein ${e}-Ergebnis senkt keinen Preis.`,en:`'result.prices' exists only for 'reduction' \u2014 a ${e} result lowers no price.`}}),n.writes!==void 0&&(e==="freetext"||e==="recommendation")&&r.push({field:"result.writes",code:Ze.writesOnProse,message:{de:`'result.writes' gibt es nur bei Ergebnissen mit Wert (Auswahl, Preisposition) \u2014 ein ${e}-Ergebnis bleibt im Chat und schreibt nichts in den Vorgang.`,en:`'result.writes' exists only for results with a value (choice, priced item) \u2014 a ${e} result stays in the chat and writes nothing to the process.`}}),e==="freetext"&&n.textRequired!==void 0&&r.push({field:"result.textRequired",code:Ze.textRequiredOnFreetext,message:{de:"'textRequired' auf einem Freitext-Ergebnis \u2014 der Text eines Freitexts ist immer Pflicht; die Angabe entfernen.",en:"'textRequired' on a free-text result \u2014 the text of a free text is always required; remove the entry."}}),n.chat===void 0)r.push({field:"result.chat",code:Ze.chatMissing,message:{de:"Ein Aufgaben-Ergebnis steht nur im Chat \u2014 'result.chat' fehlt: 'all', 'team:<Gruppe>' oder einen Kanal des Workflows angeben.",en:"A task result appears only in the chat \u2014 'result.chat' is missing: give 'all', 'team:<group>' or a channel of the workflow."}});else{let o=n.chat,a=typeof o=="string"?As(o):null;o==="external"||a===null?r.push({field:"result.chat",code:Ze.chatExternal,message:{de:`'result.chat' ${JSON.stringify(o)} \u2014 ein Aufgaben-Ergebnis bleibt intern: erlaubt sind 'all', 'team:<Gruppe>' oder ein Kanal des Workflows, nie 'external'.`,en:`'result.chat' ${JSON.stringify(o)} \u2014 a task result stays internal: 'all', 'team:<group>' or a channel of the workflow are allowed, never 'external'.`}}):a.kind==="channel"&&!t.channelKeys.has(a.channelKey)&&r.push({field:"result.chat",code:Ze.chatUnknownChannel,message:{de:`'result.chat' "${a.channelKey}" ist weder 'all' noch 'team:<Gruppe>' noch ein Kanal des Workflows (bekannt: ${[...t.channelKeys].join(", ")||"keine"}).`,en:`'result.chat' "${a.channelKey}" is neither 'all' nor 'team:<group>' nor a channel of the workflow (known: ${[...t.channelKeys].join(", ")||"none"}).`}})}return r.push(...$N(n,["kind","options","textRequired","chat","item","label","writes","fields","prices"],{de:"Aufgaben-Ergebnis",en:"task result"})),r}s(kY,"recordedIssues");function RN(e,n,t={channelKeys:new Set}){if(n===void 0)return[];if(e!=="task")return[{field:"result",code:Ze.onApproval,message:{de:`'result' gilt nur f\xFCr die Art 'task' \u2014 eine '${e}' wird durch ihr Votum abgeschlossen, nicht durch ein Ergebnis.`,en:`'result' applies only to the kind 'task' \u2014 an '${e}' is completed by its vote, not by a result.`}}];if(typeof n!="object"||n===null||Array.isArray(n))return[{field:"result",code:Ze.unknownKind,message:{de:`'result' muss ein Objekt mit 'kind' sein; bekannte Arten: ${xs.join(", ")}.`,en:`'result' must be an object with 'kind'; known kinds: ${xs.join(", ")}.`}}];let r=n;return _I(r.kind)?r.kind==="appointment"?yY(r):kY(r.kind,r,t):[{field:"result.kind",code:Ze.unknownKind,message:{de:`Unbekannte Ergebnisart ${JSON.stringify(r.kind)}; bekannte Arten: ${xs.join(", ")}.`,en:`Unknown result kind ${JSON.stringify(r.kind)}; known kinds: ${xs.join(", ")}.`}}]}s(RN,"taskResultIssues");var Ew=60;function ai(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"error"}}s(ai,"error");function bY(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"warning"}}s(bY,"warning");function IN(e){return Array.isArray(e.tasks)?e.tasks:[]}s(IN,"tasksOf");function PN(e,n){return(Array.isArray(e.optionalActions)?e.optionalActions:[]).filter(r=>r.action==="spawnTasks"&&Array.isArray(r.tasks)&&r.tasks.includes(n))}s(PN,"spawnActionsOf");function ON(e,n){return PN(e,n).map(t=>String(t.key)).sort()}s(ON,"bindingsOf");function NN(e,n){let t=[],r=IN(e),i=new Map;for(let o of r){if(o.appointment===void 0)continue;let a=typeof o.key=="string"?o.key:"?",l=`nodes.${e.id}.tasks.${a}`,d={de:`Terminaufgabe "${a}" (Knoten "${e.id}")`,en:`Appointment task "${a}" (node "${e.id}")`},c=o.appointment,p=typeof c=="object"&&c!==null&&Object.keys(c).every(T=>T==="of"||T==="dueDaysAfterEnd")&&typeof c.of=="string"?c.of:void 0,m=p===void 0?void 0:r.find(T=>T.key===p),y=m?.result;if(p===void 0||m===void 0||y?.kind!=="appointment")t.push(ai(`${l}.appointment.of`,{de:`[workItems/appointmentOfUnknown] ${d.de} braucht 'appointment: { of, dueDaysAfterEnd }', und 'of' nennt eine Aufgabe desselben Knotens, die mit einem Termin abschlie\xDFt (result.kind 'appointment'); erhalten ${JSON.stringify(o.appointment)}.`,en:`[workItems/appointmentOfUnknown] ${d.en} needs 'appointment: { of, dueDaysAfterEnd }', and 'of' names a task of the same node that ends with an appointment (result.kind 'appointment'); got ${JSON.stringify(o.appointment)}.`}));else{i.set(p,(i.get(p)??0)+1);let T=m.blocks,b=[...["when","optional"].filter(R=>m[R]!==void 0),...typeof T?.node=="string"&&T.node!==e.id?["blocks"]:[]];b.length>0&&t.push(ai(`nodes.${e.id}.tasks.${p}.${b[0]}`,{de:`[workItems/appointmentTaskShape] "${p}" bucht den Termin f\xFCr ${d.de} und tr\xE4gt ${b.map(R=>R==="blocks"?"ein knoten\xFCbergreifendes 'blocks'":`'${R}'`).join(", ")} \u2014 fiele sie ohne Buchung weg oder \xFCberlebte sie ihren Knoten, wartete die Terminaufgabe f\xFCr immer bzw. f\xE4nde die Buchung keine Terminaufgabe mehr.`,en:`[workItems/appointmentTaskShape] "${p}" books the appointment for ${d.en} and carries ${b.map(R=>R==="blocks"?"a cross-node 'blocks'":`'${R}'`).join(", ")} \u2014 if it dropped out without a booking or outlived its node, the appointment task would wait forever or the booking would find no appointment task any more.`}));for(let R of PN(e,p))R.repeatable!==!0&&t.push(ai(`nodes.${e.id}.optionalActions.${String(R.key)}.repeatable`,{de:`[workItems/appointmentActionRepeatable] Die optionale Aktion "${String(R.key)}" legt "${p}" an, die den Termin f\xFCr ${d.de} bucht, und ist nicht 'repeatable: true'. Eine Absage beendet die Runde; ohne zweite Runde lie\xDFe sich die Aktion nie wieder ausl\xF6sen, und eine Entscheidung, die auf sie wartet (requiresOneOf), bliebe h\xE4ngen.`,en:`[workItems/appointmentActionRepeatable] The optional action "${String(R.key)}" creates "${p}", which books the appointment for ${d.en}, and is not 'repeatable: true'. A cancellation ends the round; without a second round the action could never be triggered again, and a decision waiting for it (requiresOneOf) would hang.`}));ON(e,a).join(",")!==ON(e,p).join(",")&&t.push(ai(`${l}.appointment.of`,{de:`[workItems/appointmentTaskBinding] ${d.de} geh\xF6rt zu anderen optionalen Aktionen als "${p}", die ihren Termin bucht \u2014 beide Zeilen sind eine Runde: entweder beide in derselben Aktion (spawnTasks) oder beide in keiner.`,en:`[workItems/appointmentTaskBinding] ${d.en} belongs to different optional actions than "${p}", which books its appointment \u2014 both rows are one round: either both in the same action (spawnTasks) or both in none.`}))}let k=c?.dueDaysAfterEnd;(typeof k!="number"||!Number.isInteger(k)||k<0||k>Ew)&&t.push(ai(`${l}.appointment.dueDaysAfterEnd`,{de:`[workItems/appointmentTaskDue] ${d.de}: 'dueDaysAfterEnd' ist eine ganze Zahl von 0 bis ${Ew} \u2014 die Tage nach dem Terminende, bis die Aufgabe f\xE4llig ist; erhalten ${JSON.stringify(k)}.`,en:`[workItems/appointmentTaskDue] ${d.en}: 'dueDaysAfterEnd' is a whole number from 0 to ${Ew} \u2014 the days after the appointment ends until the task is due; got ${JSON.stringify(k)}.`})),o.params?.dueInDays!==void 0&&t.push(ai(`${l}.params.dueInDays`,{de:`[workItems/appointmentTaskDue] ${d.de} tr\xE4gt 'params.dueInDays' neben 'appointment.dueDaysAfterEnd' \u2014 eine Terminaufgabe ist ab dem Terminende f\xE4llig, nie ab ihrer Anlage.`,en:`[workItems/appointmentTaskDue] ${d.en} carries 'params.dueInDays' next to 'appointment.dueDaysAfterEnd' \u2014 an appointment task is due from the end of the appointment, never from its creation.`}));let g=o.result,v=["when","optional","familyRequest","reads","locksEvidence"].filter(T=>o[T]!==void 0).map(T=>`'${T}'`),E=typeof o.blocks?.node=="string"&&o.blocks.node!==e.id,A=s(T=>[...o.kind!=="task"?["'kind: approval'"]:[],...g===void 0||!Pi(g.kind)?[T==="de"?"kein erfasstes Ergebnis (Feedback)":"no recorded result (feedback)"]:[],...v,...E?[T==="de"?"ein knoten\xFCbergreifendes 'blocks'":"a cross-node 'blocks'"]:[]],"shapeFaults");A("de").length>0&&t.push(ai(`${l}.appointment`,{de:`[workItems/appointmentTaskShape] ${d.de}: ${A("de").join(", ")} \u2014 eine Terminaufgabe ist eine Aufgabe, die mit ihrem Feedback (Freitext, Empfehlung, Auswahl) abschlie\xDFt, und sie entsteht, weil der Termin entsteht: ohne Bedingung, nicht optional, keine Nachforderung, ohne Belege (nichts l\xE4sst sie ungebunden neu entstehen) und an ihrem Knoten.`,en:`[workItems/appointmentTaskShape] ${d.en}: ${A("en").join(", ")} \u2014 an appointment task is a task that ends with its feedback (free text, recommendation, choice), and it exists because the appointment exists: no condition, not optional, no follow-up request, no evidence (nothing lets it be created again unbound) and on its own node.`}));let I=o.result?.chat,_=o.assign?.group;typeof I=="string"&&I.startsWith("team:")&&typeof _=="string"&&I!==`team:${_}`&&t.push(bY(`${l}.result.chat`,{de:`[workItems/appointmentChatUnreadable] ${d.de} schreibt ihr Feedback in "${I}", geh\xF6rt aber dem Team "${_}" \u2014 die Gastgeberin bzw. der Gastgeber (ein Mitglied von "${_}") kann das eigene Feedback dort wom\xF6glich nicht lesen. 'team:${_}' oder 'all' w\xE4hlen, oder das Team als Mitglied des Chats sicherstellen.`,en:`[workItems/appointmentChatUnreadable] ${d.en} writes its feedback to "${I}", but belongs to the team "${_}" \u2014 the host (a member of "${_}") may not be able to read their own feedback there. Choose 'team:${_}' or 'all', or make sure the team is a member of the chat.`}));for(let T of n)for(let b of IN(T)){let R=b.blocks;R?.templateKey!==a||(typeof R.node=="string"?R.node:T.id)!==e.id||t.push(ai(`nodes.${T.id}.tasks.${String(b.key)}.blocks.templateKey`,{de:`[workItems/appointmentTaskBlocked] Task "${String(b.key)}" (Knoten "${T.id}") h\xE4lt ${d.de} zur\xFCck \u2014 eine Terminaufgabe wartet nur auf ihren Termin (abgeleitet aus 'appointment.of'); ein 'blocks' auf sie entf\xE4llt.`,en:`[workItems/appointmentTaskBlocked] Task "${String(b.key)}" (node "${T.id}") holds back ${d.en} \u2014 an appointment task only waits for its appointment (derived from 'appointment.of'); a 'blocks' on it is dropped.`}))}}for(let[o,a]of i)a<2||t.push(ai(`nodes.${e.id}.tasks.${o}`,{de:`[workItems/appointmentOfTwice] ${a} Terminaufgaben auf Knoten "${e.id}" geh\xF6ren zum Termin von "${o}" \u2014 ein Termin hat eine Terminaufgabe.`,en:`[workItems/appointmentOfTwice] ${a} appointment tasks on node "${e.id}" belong to the appointment of "${o}" \u2014 an appointment has one appointment task.`}));return t}s(NN,"appointmentTaskIssues");var vY="optionalAction:";function _N(e){return`${vY}${e}:trigger`}s(_N,"optionalActionTriggerActionId");var xY="processDecide";function CN(e){let n=e.optionalActions;return n==null?[]:(Array.isArray(n)||F(`[optionalAction/corrupt-section] node's 'optionalActions' is ${typeof n}, not an array \u2014 corrupt pinned graph (publish stores the section as authored)`),n)}s(CN,"optionalActionBindings");function DN(e){return CN(e).map(n=>({id:_N(n.key),kind:"internal",label:n.label,surface:xY,placement:"overflow",superUserOnly:!0}))}s(DN,"optionalActionTriggers");function FN(e){let n=new Set;for(let t of CN(e))if(t.action==="spawnTasks")for(let r of t.tasks??[])n.add(r);return n}s(FN,"referencedTaskTemplateKeys");var At={notOptionalAction:"[workItems/familyRequestNotOptionalAction]",notTask:"[workItems/familyRequestNotTask]",closedOtherwise:"[workItems/familyRequestClosedOtherwise]",blocks:"[workItems/familyRequestBlocks]",noDeadline:"[workItems/familyRequestNoDeadline]",fields:"[workItems/familyRequestFields]",unknownField:"[workItems/familyRequestUnknownField]",shape:"[workItems/familyRequestShape]",twicePerAction:"[workItems/familyRequestTwicePerAction]",deadlock:"[workItems/familyRequestOnlyWayButAsked]"};function Et(e,n,t){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:{de:`${n} ${t.de}`,en:`${n} ${t.en}`},severity:"error"}}s(Et,"issue");function SY(e,n,t){return e.flatMap(r=>(Array.isArray(r.tasks)?r.tasks:[]).filter(i=>{let o=i.blocks,a=typeof o?.node=="string"?o.node:r.id;return o?.templateKey===t&&a===n}).map(i=>({nodeId:r.id,key:String(i.key)})))}s(SY,"blockersOf");function LN(e){let{graph:n,node:t,task:r}=e,i=r.familyRequest;if(i===void 0)return[];let o=typeof r.key=="string"?r.key:"?",a=`nodes.${t.id}.tasks.${o}`,l={de:`Task "${o}" auf Knoten \u201E${Oe(n,t.id,"de")}\u201C (${t.id})`,en:`Task "${o}" on node "${Oe(n,t.id,"en")}" (${t.id})`},d=[];if(typeof i!="object"||i===null||Array.isArray(i))return[Et(`${a}.familyRequest`,At.shape,{de:`${l.de}: 'familyRequest' muss ein Objekt { fields } oder { from } sein.`,en:`${l.en}: 'familyRequest' must be an object { fields } or { from }.`})];let c=Object.keys(i).filter(k=>k!=="fields"&&k!=="from");c.length>0&&d.push(Et(`${a}.familyRequest.${c[0]}`,At.shape,{de:`${l.de}: 'familyRequest' kennt nur 'fields' oder 'from', nicht ${c.map(k=>`'${k}'`).join(", ")} \u2014 was angefordert wird und der Text an die Familie werden beim Ausl\xF6sen gew\xE4hlt.`,en:`${l.en}: 'familyRequest' only knows 'fields' or 'from', not ${c.map(k=>`'${k}'`).join(", ")} \u2014 what is requested and the text to the family are chosen when the action is triggered.`}));let{fields:u,from:p}=i;u===void 0==(p===void 0)&&d.push(Et(`${a}.familyRequest`,At.shape,{de:`${l.de}: 'familyRequest' nennt genau eines \u2014 'fields' (die anforderbaren Felder) oder 'from' (das Formular, dessen Dateifelder alle zur Wahl stehen).`,en:`${l.en}: 'familyRequest' names exactly one \u2014 'fields' (the fields that can be requested) or 'from' (the form whose file fields are all available).`})),e.onTrigger.has(o)||d.push(Et(`${a}.familyRequest`,At.notOptionalAction,{de:`${l.de} fordert bei der Familie an, geh\xF6rt aber zu keiner optionalen Aktion (spawnTasks) \u2014 nur deren Ausl\xF6sen \xF6ffnet die Anfrage an die Familie.`,en:`${l.en} requests from the family but belongs to no optional action (spawnTasks) \u2014 only triggering one opens the request to the family.`})),r.kind!=="task"&&d.push(Et(`${a}.kind`,At.notTask,{de:`${l.de} fordert bei der Familie an und muss die Art 'task' haben, nicht ${JSON.stringify(r.kind)}.`,en:`${l.en} requests from the family and must have the kind 'task', not ${JSON.stringify(r.kind)}.`}));for(let k of["result","when","locksEvidence","gatesNode"])r[k]!==void 0&&d.push(Et(`${a}.${k}`,At.closedOtherwise,{de:`${l.de} wartet auf die Familie und erledigt sich mit ihrer Antwort \u2014 '${k}' passt nicht dazu.`,en:`${l.en} waits for the family and completes with their answer \u2014 '${k}' does not fit that.`}));r.blocks!==void 0&&d.push(Et(`${a}.blocks`,At.blocks,{de:`${l.de} wartet auf die Familie und darf nichts zur\xFCckhalten ('blocks') \u2014 sie h\xE4lt ihren Knoten schon als Aufgabe einer optionalen Aktion.`,en:`${l.en} waits for the family and must not hold anything back ('blocks') \u2014 as the task of an optional action it already holds its node.`}));for(let k of SY(n.nodes,t.id,o))d.push(Et(`nodes.${k.nodeId}.tasks.${k.key}.blocks`,At.blocks,{de:`Task "${k.key}" auf Knoten "${k.nodeId}" h\xE4lt ${l.de} zur\xFCck \u2014 eine Nachforderung darf nie zur\xFCckgehalten werden: zur\xFCckgehalten h\xE4tte sie keine Frist und k\xF6nnte mit der Antwort der Familie nicht erledigt werden.`,en:`Task "${k.key}" on node "${k.nodeId}" holds back ${l.en} \u2014 a follow-up request must never be held back: held back, it would have no deadline and could not be completed by the family's answer.`}));let m=r.params?.dueInDays;if((typeof m!="number"||!Number.isInteger(m)||m<1)&&d.push(Et(`${a}.params.dueInDays`,At.noDeadline,{de:`${l.de} fordert bei der Familie an und braucht eine Frist in ganzen Tagen ('params.dueInDays' \u2265 1) \u2014 sie ist die Frist der Familie und Anlass der Erinnerung.`,en:`${l.en} requests from the family and needs a deadline in whole days ('params.dueInDays' \u2265 1) \u2014 it is the family's deadline and the reason for the reminder.`})),u===void 0)return d;if(!Array.isArray(u)||u.length===0)return d.push(Et(`${a}.familyRequest.fields`,At.fields,{de:`${l.de}: 'familyRequest.fields' muss mindestens ein Feld eines Formulars nennen \u2014 oder statt dessen 'from' das Formular, dann stehen alle seine Dateifelder zur Wahl.`,en:`${l.en}: 'familyRequest.fields' must name at least one field of a form \u2014 or 'from' the form instead, then all its file fields are available.`})),d;let y=new Set;for(let k of u){if(!we(k))continue;let g=se(k);if(y.has(g)){d.push(Et(`${a}.familyRequest.fields`,At.fields,{de:`${l.de}: 'familyRequest.fields' nennt ${Ve(n,k,"de")} mehrfach.`,en:`${l.en}: 'familyRequest.fields' names ${Ve(n,k,"en")} more than once.`}));continue}y.add(g),fn(k)||d.push(Et(`${a}.familyRequest.fields`,At.unknownField,{de:`${l.de}: 'familyRequest.fields' nennt ${Ve(n,k,"de")} \u2014 anfordern l\xE4sst sich nur ein Feld eines Formulars ($node.<formular>.admission.<feld>).`,en:`${l.en}: 'familyRequest.fields' names ${Ve(n,k,"en")} \u2014 only a field of a form ($node.<form>.admission.<field>) can be requested.`}))}return d}s(LN,"familyRequestIssues");function MN(e){let n=new Set((Array.isArray(e.tasks)?e.tasks:[]).flatMap(r=>r.familyRequest!==void 0&&typeof r.key=="string"?[r.key]:[]));return(Array.isArray(e.optionalActions)?e.optionalActions:[]).flatMap((r,i)=>{if(r.action!=="spawnTasks"||!Array.isArray(r.tasks))return[];let o=r.tasks.filter(a=>typeof a=="string"&&n.has(a));return o.length<=1?[]:[Et(`nodes.${e.id}.optionalActions.${i}.tasks`,At.twicePerAction,{de:`Optionale Aktion \u201E${String(r.key)}\u201C auf Knoten "${e.id}" startet ${o.length} Nachforderungen (${o.join(", ")}) \u2014 ein Ausl\xF6sen fragt die Familie nach EINER Sache; h\xF6chstens eine Nachforderung je Aktion.`,en:`Optional action "${String(r.key)}" on node "${e.id}" starts ${o.length} follow-up requests (${o.join(", ")}) \u2014 one trigger asks the family for ONE thing; at most one follow-up request per action.`})]})}s(MN,"familyRequestActionIssues");function qN(e,n){let t=e.nodes,r=new Map;for(let a of t)if(!(a.type!=="completenessCheck"||!Array.isArray(a.requires)))for(let l of a.requires)fn(l)&&r.set(se(l),l);if(r.size===0)return[];let i=s(a=>{let l=oi(n,a);return l===void 0||l!==null&&l.kind==="entered"&&l.type==="docRef"},"isFileField"),o=s(a=>{let{fields:l,from:d}=a??{};return Array.isArray(l)?l.filter(fn):!we(d)||d.scope!=="node"?[]:[...r.values()].filter(c=>c.owner===d.owner&&i(c))},"offeredBy");return t.flatMap(a=>{let l=Array.isArray(a.requiresOneOf)?a.requiresOneOf:[],c=(Array.isArray(a.optionalActions)?a.optionalActions:[]).filter(m=>l.includes(m.key)),u=Array.isArray(a.tasks)?a.tasks:[];return c.filter(m=>Array.isArray(m.tasks)&&c.every(y=>y===m||y.when!==void 0)).flatMap(m=>u.flatMap(y=>{if(y.familyRequest===void 0||!m.tasks.includes(y.key))return[];let k=o(y.familyRequest).filter(g=>r.has(se(g)));return k.length===0?[]:[{...Et(`nodes.${a.id}.requiresOneOf`,At.deadlock,{de:`Auf Knoten \u201E${Oe(e,a.id,"de")}\u201C (${a.id}) ist die Nachforderung \u201E${String(m.key)}\u201C der einzige Weg durch 'requiresOneOf', und eine Vollst\xE4ndigkeitspr\xFCfung fragt dieselben Felder an (${k.map(g=>Ve(e,g,"de")).join(", ")}). Ist deren Anfrage offen, lassen sich diese Felder nicht nachfordern \u2014 die Entscheidung bliebe gesperrt. Eine zweite Aktion in 'requiresOneOf' oder andere Felder l\xF6sen das.`,en:`On node "${Oe(e,a.id,"en")}" (${a.id}) the follow-up request "${String(m.key)}" is the only way through 'requiresOneOf', and a completeness check asks for the same fields (${k.map(g=>Ve(e,g,"en")).join(", ")}). While its request is open, these fields cannot be requested \u2014 the decision would stay locked. A second action in 'requiresOneOf' or other fields solve this.`}),severity:"warning"}]}))})}s(qN,"familyRequestDeadlockWarnings");var Tw={key:!0,kind:!0,title:!0,assign:!0,gatesNode:!0,blocks:!0,completableIf:!0,result:!0,when:!0,onConditionReturn:!0,reads:!0,locksEvidence:!0,description:!0,documents:!0,formView:!0,familyRequest:!0,optional:!0,appointment:!0,params:!0};function AY(e){let n=He(e);return new Map((typeof n.workItemTemplates=="function"?n.workItemTemplates(e):[]).map(t=>[t.key,t]))}s(AY,"intrinsicTemplatesOf");function KN(e,n,t){if(t!==void 0&&typeof t!="string")return null;let r=t??n,i=e.nodes.find(l=>l.id===r);if(i===void 0)return null;let o=i,a=He(i);return{node:o,composedKeys:new Set((Array.isArray(o.tasks)?o.tasks:[]).map(l=>l.key).filter(l=>typeof l=="string")),intrinsicByKey:AY(i),refuse:s(l=>typeof a.refuseBlocksTarget=="function"?a.refuseBlocksTarget(i,l):null,"refuse")}}s(KN,"resolveBlocksTargetNode");function EY(e){let n=new Map;for(let r of Qt(e.nodes)){let i=n.get(r.source)??[];i.push(r.target),n.set(r.source,i)}let t=new Map;return r=>{let i=t.get(r);if(i!==void 0)return i;let o=new Set,a=[...n.get(r)??[]];for(;a.length>0;){let l=a.shift();o.has(l)||(o.add(l),a.push(...n.get(l)??[]))}return t.set(r,o),o}}s(EY,"reachability");function jN(e){let n=[],t=new Map;for(let o of e.nodes){let a=o;for(let l of Array.isArray(a.tasks)?a.tasks:[]){let d=typeof l.key=="string"?l.key:void 0,c=l.blocks;if(d===void 0||typeof c?.templateKey!="string")continue;let u=typeof c.node=="string"?c.node:o.id;t.set(`${o.id}::${d}`,`${u}::${c.templateKey}`)}}let r=new Map,i=s((o,a)=>{if(r.get(o)==="done")return;if(r.get(o)==="visiting"){let d=[...a.slice(a.indexOf(o)),o],[c,u]=o.split("::");n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${c}.tasks.${u}.blocks`,reason:{de:`[workItems/blocksCycle] Zyklus im 'blocks'-Graphen: ${d.map(p=>`"${p.replace("::"," \xB7 ")}"`).join(" \u2192 ")} \u2014 jedes Mitglied w\xFCrde auf ein anderes warten, keines w\xFCrde je frei.`,en:`[workItems/blocksCycle] Cycle in the 'blocks' graph: ${d.map(p=>`"${p.replace("::"," \xB7 ")}"`).join(" \u2192 ")} \u2014 every member would wait for another, none would ever be released.`},severity:"error"});return}r.set(o,"visiting");let l=t.get(o);l!==void 0&&t.has(l)&&i(l,[...a,o]),r.set(o,"done")},"walk");for(let o of t.keys())i(o,[]);return n}s(jN,"checkBlocksCycles");function TY(e){let{requiresOneOf:n,optionalActions:t}=e;if(!Array.isArray(n)||!Array.isArray(t))return new Set;let r=new Set(n.filter(o=>typeof o=="string")),i=new Set;for(let o of t)if(!(typeof o.key!="string"||!r.has(o.key)||!Array.isArray(o.tasks)))for(let a of o.tasks)typeof a=="string"&&i.add(a);return i}s(TY,"tasksOfRequiresOneOf");function BN(e){if(typeof e!="object"||e===null)return!1;let{de:n,en:t}=e;return typeof n=="string"&&n.trim().length>0&&typeof t=="string"&&t.trim().length>0}s(BN,"isFilledBilingual");var $Y=["blocks","gatesNode","locksEvidence","completableIf"];function RY(e,n){let t=[],r={de:`Task "${n.key}" (Knoten "${n.nodeId}")`,en:`Task "${n.key}" (node "${n.nodeId}")`},i=e.optional;(!(typeof i=="object"&&i!==null&&Object.keys(i).every(d=>d==="skipLabel"))||!BN(i.skipLabel))&&t.push(Wn(`${n.base}.optional.skipLabel`,{de:`[workItems/optionalSkipLabel] ${r.de} ist optional, braucht daf\xFCr '{ skipLabel: { de, en } }' \u2014 die Worte des Knopfs, mit dem die zust\xE4ndige Person ohne Ergebnis abschlie\xDFt (\u201EKeine Einsch\xE4tzung abgeben"); erhalten ${JSON.stringify(i)}.`,en:`[workItems/optionalSkipLabel] ${r.en} is optional and needs '{ skipLabel: { de, en } }' for that \u2014 the words of the button the responsible person uses to finish without a result ("Give no assessment"); got ${JSON.stringify(i)}.`})),e.kind!=="task"&&t.push(Wn(`${n.base}.optional`,{de:`[workItems/optionalOnApproval] ${r.de} ist eine Freigabe \u2014 optional ist nur eine Aufgabe; eine Freigabe schlie\xDFt mit ihrem Urteil.`,en:`[workItems/optionalOnApproval] ${r.en} is an approval \u2014 only a task can be optional; an approval ends with its verdict.`}));let a=e.result;(a===void 0||typeof a.kind!="string"||!CI({kind:a.kind,writes:a.writes}))&&t.push(Wn(`${n.base}.optional`,{de:`[workItems/optionalNeedsProseResult] ${r.de} ist optional, schlie\xDFt aber ${a===void 0?"ohne Ergebnis":`mit einem ${String(a.kind)}-Ergebnis${a.writes!==void 0?" mit Wert":""}`} \u2014 optional ist nur eine Aufgabe mit Freitext, Empfehlung oder einer Auswahl ohne 'writes': einen Wert, den ein sp\xE4terer Schritt liest, g\xE4be es dann nie.`,en:`[workItems/optionalNeedsProseResult] ${r.en} is optional but ends ${a===void 0?"without a result":`with a ${String(a.kind)} result${a.writes!==void 0?" with a value":""}`} \u2014 only a task with free text, a recommendation or a choice without 'writes' can be optional: a value a later step reads would then never arrive.`}));let l=$Y.filter(d=>e[d]!==void 0);return l.length>0&&t.push(Wn(`${n.base}.${l[0]}`,{de:`[workItems/optionalHolds] ${r.de} ist optional und tr\xE4gt ${l.map(d=>`'${d}'`).join(", ")} \u2014 auf eine optionale Aufgabe wartet nichts: sie h\xE4lt keinen Schritt zur\xFCck. Entweder optional oder zur\xFCckhaltend.`,en:`[workItems/optionalHolds] ${r.en} is optional and carries ${l.map(d=>`'${d}'`).join(", ")} \u2014 nothing waits for an optional task: it holds no step back. Either optional or holding back.`})),n.requiredByRule&&t.push(Wn(`${n.base}.optional`,{de:`[workItems/optionalInRequiresOneOf] ${r.de} ist optional, geh\xF6rt aber zu einer Aktion, die 'requiresOneOf' verlangt \u2014 \u201EKeine Einsch\xE4tzung abgeben" w\xFCrde die Regel erf\xFCllen, ohne dass etwas geschehen ist.`,en:`[workItems/optionalInRequiresOneOf] ${r.en} is optional but belongs to an action that 'requiresOneOf' requires \u2014 "Give no assessment" would satisfy the rule without anything having happened.`})),t}s(RY,"optionalTaskIssues");function Wn(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"error"}}s(Wn,"issue");function VN(e,n){let t=[],r=EY(e),i=new Set(Qs(e).map(o=>o.key));t.push(...qN(e,n));for(let o of e.nodes){let a=o,l=FN(a);t.push(...MN(a));let d=TY(a);t.push(...NN(a,e.nodes));for(let c of Array.isArray(a.tasks)?a.tasks:[]){let u=typeof c.key=="string"?c.key:"?",p=`nodes.${o.id}.tasks.${u}`,m=c.kind,y=c.result,k=c.blocks,g=typeof k?.node=="string"&&k.node!==o.id?k.node:void 0;if(typeof k?.templateKey=="string"){let R=typeof k.node=="string"?k.node:o.id,q=e.nodes.find(Y=>Y.id===R),J=(Array.isArray(q?.tasks)?q.tasks:[]).find(Y=>Y.key===k.templateKey)?.blocks;typeof J?.node=="string"&&J.node!==R&&t.push(Wn(`${p}.blocks.templateKey`,{de:`[workItems/blocksCrossNodeTask] Task "${u}" auf Knoten "${o.id}" h\xE4lt "${k.templateKey}" auf Knoten "${R}" zur\xFCck \u2014 das ist selbst eine knoten\xFCbergreifende Aufgabe, die ihren Knoten \xFCberlebt; zur\xFCckgehalten k\xF6nnte sie nach dessen Verlassen weder bearbeitet noch freigegeben werden. Nur Aufgaben, die an ihrem Knoten bleiben, und intrinsische Vorlagen sind Ziele.`,en:`[workItems/blocksCrossNodeTask] Task "${u}" on node "${o.id}" holds back "${k.templateKey}" on node "${R}" \u2014 that is itself a cross-node task that outlives its node; held back, it could be neither worked nor released after the node is left. Only tasks that stay on their node and intrinsic templates are targets.`}))}if(g!==void 0){let R=g;e.nodes.some(q=>q.id===R)&&!r(o.id).has(R)&&t.push(Wn(`${p}.blocks.node`,{de:`[workItems/blocksTargetNotAfter] Task "${u}" auf Knoten "${o.id}" blockiert Knoten "${R}", der von hier aus nicht erreichbar ist \u2014 die Aufgabe entst\xFCnde erst, wenn ihr Ziel schon hinter dem Prozess liegt. Ziel ist derselbe Knoten oder ein sp\xE4terer.`,en:`[workItems/blocksTargetNotAfter] Task "${u}" on node "${o.id}" blocks node "${R}", which cannot be reached from here \u2014 the task would only be created when its target is already behind the process. The target is the same node or a later one.`})),(y===void 0||!Pi(y.kind))&&t.push(Wn(`${p}.blocks.node`,{de:`[workItems/crossNodeBlocksNeedsResult] Task "${u}" auf Knoten "${o.id}" blockiert einen anderen Knoten ("${R}"), hat aber kein 'result' \u2014 eine knoten\xFCbergreifende Aufgabe \xFCberlebt ihren Knoten und wird \xFCber ihr Ergebnis abgeschlossen (Freitext, Empfehlung oder Auswahl).`,en:`[workItems/crossNodeBlocksNeedsResult] Task "${u}" on node "${o.id}" blocks another node ("${R}") but has no 'result' \u2014 a cross-node task outlives its node and is completed through its result (free text, recommendation or choice).`})),l.has(u)&&t.push(Wn(`${p}.blocks.node`,{de:`[optionalAction/crossNodeBlocks] Task "${u}" geh\xF6rt zu einer optionalen Aktion (spawnTasks) auf Knoten "${o.id}" und darf keinen anderen Knoten blockieren \u2014 ihre Zeilen sind die Runde der Aktion.`,en:`[optionalAction/crossNodeBlocks] Task "${u}" belongs to an optional action (spawnTasks) on node "${o.id}" and must not block another node \u2014 its rows are the round of the action.`}))}for(let R of RN(String(m),y,{channelKeys:i,...n?.billingItemKeys!==void 0?{billingItemKeys:n.billingItemKeys}:{},...n?.offerProgram!==void 0?{offerProgram:n.offerProgram}:{}}))t.push(Wn(`${p}.${R.field}`,{de:`${R.code} ${R.message.de} (Task "${u}" auf Knoten "${o.id}").`,en:`${R.code} ${R.message.en} (task "${u}" on node "${o.id}").`}));let v=c.when,E=s((R,q,P)=>{!we(q)||fn(q)||t.push(Wn(R,{de:`[workItems/evidenceNotFormField] ${P} auf Task "${u}" (Knoten "${o.id}") nennt ${Ve(e,q,"de")} \u2014 Bedingung und Belege einer Aufgabe sind Felder eines Formulars ($node.<formular>.admission.<feld>).`,en:`[workItems/evidenceNotFormField] ${P} on task "${u}" (node "${o.id}") names ${Ve(e,q,"en")} \u2014 the condition and evidence of a task are fields of a form ($node.<form>.admission.<field>).`}))},"notFormField");v!==void 0?(E(`${p}.when`,v,"'when'"),c.onConditionReturn!=="respawn"&&c.onConditionReturn!=="stayClosed"&&t.push(Wn(`${p}.onConditionReturn`,{de:`[workItems/whenNeedsOnConditionReturn] Task "${u}" (Knoten "${o.id}") hat eine Bedingung, aber kein 'onConditionReturn' ('respawn' | 'stayClosed') \u2014 was bei der R\xFCckkehr der Bedingung geschieht, muss entschieden sein.`,en:`[workItems/whenNeedsOnConditionReturn] Task "${u}" (node "${o.id}") has a condition but no 'onConditionReturn' ('respawn' | 'stayClosed') \u2014 what happens when the condition returns must be decided.`}))):c.onConditionReturn!==void 0&&t.push(Wn(`${p}.onConditionReturn`,{de:`[workItems/whenNeedsOnConditionReturn] 'onConditionReturn' ohne 'when' auf Task "${u}" (Knoten "${o.id}") \u2014 ohne Bedingung kehrt nichts zur\xFCck.`,en:`[workItems/whenNeedsOnConditionReturn] 'onConditionReturn' without 'when' on task "${u}" (node "${o.id}") \u2014 without a condition nothing returns.`}));let A=c.reads;if(A!==void 0)if(!Array.isArray(A))t.push(Wn(`${p}.reads`,{de:`[workItems/readsUnknownField] 'reads' auf Task "${u}" (Knoten "${o.id}") muss eine Liste von Feldadressen sein.`,en:`[workItems/readsUnknownField] 'reads' on task "${u}" (node "${o.id}") must be a list of field addresses.`}));else for(let[R,q]of A.entries())E(`${p}.reads.${R}`,q,"'reads'");let I=c.locksEvidence,_=s((R,q)=>t.push(Wn(`${p}.locksEvidence`,{de:`[workItems/${R}] Task "${u}" (Knoten "${o.id}") ${q.de}`,en:`[workItems/${R}] Task "${u}" (node "${o.id}") ${q.en}`})),"lockIssue");I!==void 0&&I!==!0&&_("locksEvidenceNotTrue",{de:`tr\xE4gt 'locksEvidence' ${JSON.stringify(I)} \u2014 nur 'true' ist erlaubt; ohne Sperre entf\xE4llt das Feld.`,en:`carries 'locksEvidence' ${JSON.stringify(I)} \u2014 only 'true' is allowed; without a lock the field is dropped.`}),I===!0&&(A===void 0&&v===void 0&&_("locksEvidenceWithoutEvidence",{de:"sperrt seine Belege, hat aber weder 'reads' noch 'when' \u2014 es gibt nichts, worauf die Entscheidung beruht.",en:"locks its evidence but has neither 'reads' nor 'when' \u2014 there is nothing the decision rests on."}),(y===void 0||!Pi(y.kind))&&_("locksEvidenceNeedsRecordedResult",{de:"sperrt seine Belege, schlie\xDFt aber nicht mit einem erfassten Ergebnis (Freitext, Empfehlung, Auswahl) \u2014 nur eine Entscheidung, die das Team wieder\xF6ffnen kann, darf Belege sperren (ein Termin bleibt gebucht).",en:"locks its evidence but does not end with a recorded result (free text, recommendation, choice) \u2014 only a decision the team can reopen may lock evidence (an appointment stays booked)."}),l.has(u)&&_("locksEvidenceOnOptionalAction",{de:"geh\xF6rt zu einer optionalen Aktion (spawnTasks) \u2014 ihre Zeilen sind die Runde der Aktion, wieder\xF6ffnen l\xE4sst sie sich nicht; Belege sperrt nur eine Knotenaufgabe.",en:"belongs to an optional action (spawnTasks) \u2014 its rows are the round of the action and cannot be reopened; only a node task locks evidence."})),t.push(...LN({graph:e,node:a,task:c,onTrigger:l,specCtx:n}));let T=Object.keys(c).filter(R=>!Object.hasOwn(Tw,R));T.length>0&&t.push(Wn(`${p}.${T[0]}`,{de:`[workItems/unknownKey] Task "${u}" (Knoten "${o.id}") tr\xE4gt ${T.map(R=>`'${R}'`).join(", ")} \u2014 kein Feld einer Aufgabe. Erlaubt: ${Object.keys(Tw).join(", ")}. (Checklisten gibt es nicht mehr: Text als 'description', mehrere Arbeitsschritte sind mehrere Aufgaben.)`,en:`[workItems/unknownKey] Task "${u}" (node "${o.id}") carries ${T.map(R=>`'${R}'`).join(", ")} \u2014 not a field of a task. Allowed: ${Object.keys(Tw).join(", ")}. (Checklists no longer exist: text goes in 'description', several work steps are several tasks.)`}));let b=c.description;b!==void 0&&!BN(b)&&t.push(Wn(`${p}.description`,{de:`[workItems/descriptionInvalid] 'description' auf Task "${u}" (Knoten "${o.id}") braucht Text in beiden Sprachen ({ de, en }), erhalten ${JSON.stringify(b)}.`,en:`[workItems/descriptionInvalid] 'description' on task "${u}" (node "${o.id}") needs text in both languages ({ de, en }), got ${JSON.stringify(b)}.`})),c.optional!==void 0&&t.push(...RY(c,{key:u,nodeId:o.id,base:p,requiredByRule:d.has(u)}))}}return t}s(VN,"checkNodeTasks");function UN(e){let n=e.indexOf(":"),t=n===-1?"":e.slice(0,n),r=n===-1?"":e.slice(n+1).trim();if(t==="artifact"&&r.length>0)return{kind:t,key:r};let i=Zr(r);return(t==="field"||t==="document")&&i!==null?{kind:t,address:i}:le("INVALID",{de:`Dokument-Verweis "${e}" ist ung\xFCltig \u2014 erwartet artifact:<Slot-Schl\xFCssel>, field:$node.<Formular>.admission.<Feld> oder document:$node.<Knoten>.document.`,en:`Document reference "${e}" is invalid \u2014 expected artifact:<slot key>, field:$node.<form>.admission.<field> or document:$node.<node>.document.`})}s(UN,"parseTaskDocumentRef");function $w(e){return e.kind==="artifact"?`artifact:${e.key}`:`${e.kind}:${se(e.address)}`}s($w,"taskDocumentId");function li(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"error"}}s(li,"issue");function GN(e){return Array.isArray(e.tasks)?e.tasks:[]}s(GN,"tasksOf");function IY(e){let n=new Map;for(let t of e){let{id:r,artifacts:i}=t;for(let o of Array.isArray(i)?i:[])typeof o?.key=="string"&&n.set(o.key,[...n.get(o.key)??[],{nodeId:r,slot:o}])}return n}s(IY,"artifactSlotDeclarations");function OY(e){return e.flatMap(n=>{let{id:t,artifacts:r}=n;return(Array.isArray(r)?r:[]).filter(i=>!qf(i?.type)).map(i=>({nodeId:String(t),slotKey:String(i?.key),type:JSON.stringify(i?.type??null)}))})}s(OY,"unknownArtifactSlotTypes");function zN(e){let n=[];for(let{nodeId:t,slotKey:r,type:i}of OY(e.nodes))n.push(li(`nodes.${t}.artifacts.${r}.type`,{de:`[artifact/unknownType] Knoten "${t}" deklariert den Dokument-Slot \u201E${r}" mit der Art ${i} \u2014 erlaubt sind ${js.join(", ")}.`,en:`[artifact/unknownType] Node "${t}" declares the document slot "${r}" with the type ${i} \u2014 allowed are ${js.join(", ")}.`}));for(let[t,r]of IY(e.nodes))for(let i of r.slice(1))n.push(li(`nodes.${i.nodeId}.artifacts`,{de:`[governedDocument/slotKeyTaken] Knoten "${i.nodeId}" deklariert den Dokument-Slot \u201E${t}", den schon "${r[0].nodeId}" deklariert \u2014 jeder Slot-Schl\xFCssel geh\xF6rt genau einem Knoten.`,en:`[governedDocument/slotKeyTaken] Node "${i.nodeId}" declares the document slot "${t}", which "${r[0].nodeId}" already declares \u2014 every slot key belongs to exactly one node.`}));return n}s(zN,"checkArtifactSlotKeys");function WN(e){if(!Array.isArray(e)||e.length===0)return null;let n=[];for(let t of e){let r=typeof t=="object"&&t!==null?t:{},i=Object.keys(r).sort().join(",");if(r.kind==="artifact"&&i==="key,kind"&&typeof r.key=="string"&&r.key.length>0)n.push({kind:"artifact",key:r.key});else if((r.kind==="field"||r.kind==="document")&&i==="address,kind")n.push({kind:r.kind,address:r.address});else return null}return n}s(WN,"authoredRefs");function PY(e){return e.scope==="node"&&(e.key===wl||e.key===Ts||e.key===$s)&&e.path===void 0}s(PY,"isDocumentAddress");function YN(e){let n=[];for(let t of e.nodes)for(let r of GN(t)){if(r.documents===void 0)continue;let i=typeof r.key=="string"?r.key:"?",o=`nodes.${t.id}.tasks.${i}.documents`,a={de:`Task "${i}" (Knoten "${t.id}")`,en:`Task "${i}" (node "${t.id}")`},l=WN(r.documents);if(l===null){n.push(li(o,{de:`[workItems/documentsInvalid] 'documents' auf ${a.de} muss eine nicht leere Liste von { kind: 'artifact', key } (eigener Slot), { kind: 'field', address } (Dateifeld eines Formulars) oder { kind: 'document', address } (Dokument eines anderen Knotens) sein, erhalten ${JSON.stringify(r.documents)}.`,en:`[workItems/documentsInvalid] 'documents' on ${a.en} must be a non-empty list of { kind: 'artifact', key } (own slot), { kind: 'field', address } (file field of a form) or { kind: 'document', address } (document of another node), got ${JSON.stringify(r.documents)}.`}));continue}let d=new Set;for(let c of l){if(c.kind!=="artifact"&&!we(c.address))continue;let u=c.kind==="artifact"?$w(c):$w({kind:c.kind,address:c.address});d.has(u)&&n.push(li(o,{de:`[workItems/documentsDuplicate] ${a.de} verweist zweimal auf ${u}.`,en:`[workItems/documentsDuplicate] ${a.en} refers to ${u} twice.`})),d.add(u),c.kind==="artifact"&&!sO(t,c.key)&&n.push(li(o,{de:`[workItems/documentsUnknownArtifact] ${a.de} verweist auf das Dokument "${c.key}", aber der Knoten deklariert keinen solchen Slot \u2014 das Dokument eines anderen Knotens ist { kind: 'document', address: $node.<knoten>.document }.`,en:`[workItems/documentsUnknownArtifact] ${a.en} refers to the document "${c.key}", but the node declares no such slot \u2014 the document of another node is { kind: 'document', address: $node.<node>.document }.`})),c.kind==="field"&&!fn(c.address)&&n.push(li(o,{de:`[workItems/documentsInvalid] ${a.de}: ein Feld-Dokument nennt ein Feld eines Formulars ($node.<formular>.admission.<feld>), nicht ${Ve(e,c.address,"de")}.`,en:`[workItems/documentsInvalid] ${a.en}: a field document names a field of a form ($node.<form>.admission.<field>), not ${Ve(e,c.address,"en")}.`})),c.kind==="document"&&!PY(c.address)&&n.push(li(o,{de:`[workItems/documentsInvalid] ${a.de}: ein Dokument eines anderen Knotens ist dessen ganzes Dokument ($node.<knoten>.document), nicht ${se(c.address)}.`,en:`[workItems/documentsInvalid] ${a.en}: a document of another node is that node's whole document ($node.<node>.document), not ${se(c.address)}.`}))}}return n}s(YN,"checkTaskDocuments");function HN(e,n){let t=[];for(let r of e.nodes)for(let i of GN(r)){let o=WN(i.documents);if(o===null)continue;let a=typeof i.key=="string"?i.key:"?",l=`nodes.${r.id}.tasks.${a}.documents`;for(let d of o){if(d.kind!=="field"||!fn(d.address))continue;let c=oi(n,d.address);if(c==null)continue;let u={de:Ve(e,d.address,"de"),en:Ve(e,d.address,"en")},p=Fs("taskDocument",Ds(c));if(p==="repeated"){t.push(li(l,{de:`[workItems/documentsUnknownField] Task "${a}" (Knoten "${r.id}") verweist auf das Feld ${u.de} \u2014 ein Feld in einer Wiederholgruppe ist kein einzelnes Dokument der Anmeldung.`,en:`[workItems/documentsUnknownField] Task "${a}" (node "${r.id}") refers to the field ${u.en} \u2014 a field in a repeated group is not a single document of the application.`}));continue}p==="notDocument"&&t.push(li(l,{de:`[workItems/documentsNotDocument] Task "${a}" (Knoten "${r.id}") verweist auf das Feld ${u.de}, das keine Datei enth\xE4lt \u2014 nur Datei-Felder (docRef) sind Dokumente.`,en:`[workItems/documentsNotDocument] Task "${a}" (node "${r.id}") refers to the field ${u.en}, which holds no file \u2014 only file fields (docRef) are documents.`}))}}return t}s(HN,"checkTaskDocumentFields");var Rw=["form","documents"],NY=/^[a-z][a-zA-Z0-9_-]*$/;function _Y(e){let n=new Map,t=s(r=>{for(let i of[...r.fields,...(r.groups??[]).flatMap(o=>o.fields)])n.set(i.key,i.type==="docRef"?"document":"other");for(let i of r.repeated??[]){n.set(i.key,"other");for(let o of i.itemTemplate)n.set(`${i.key}[].${o.key}`,o.type==="docRef"?"row":"other")}r.subsections?.forEach(t)},"visit");return e.sections.forEach(t),n}s(_Y,"fieldPlaces");function JN(e,n,t){let r=[],i=new Set;return e.forEach((o,a)=>{if(typeof o!="string"||!NY.test(o)){r.push({severity:"error",path:`${t(a)}.key`,code:"view.invalid-key",message:{de:`${n.de}: '${String(o)}' ist kein g\xFCltiger Schl\xFCssel (Kleinbuchstabe am Anfang, dann Buchstaben, Ziffern, - oder _).`,en:`${n.en}: '${String(o)}' is no valid key (a lower-case letter first, then letters, digits, - or _).`}});return}i.has(o)&&r.push({severity:"error",path:`${t(a)}.key`,code:"view.duplicate-key",message:{de:`${n.de}: Der Schl\xFCssel '${o}' kommt doppelt vor.`,en:`${n.en}: the key '${o}' occurs twice.`}}),i.add(o)}),r}s(JN,"keyIssues");function CY(e,n,t){return e==="document"?null:e===void 0?{severity:"error",path:t,code:"view.unknown-field",message:{de:`Ansicht: Das Formular hat kein Feld '${n}'.`,en:`View: the form has no field '${n}'.`}}:e==="row"?{severity:"error",path:t,code:"view.field-in-row",message:{de:`Ansicht: Das Dateifeld '${n}' liegt in einem wiederholten Block und kann nicht einzeln genannt werden.`,en:`View: the file field '${n}' sits in a repeated block and cannot be named on its own.`}}:{severity:"error",path:t,code:"view.not-a-document",message:{de:`Ansicht: Das Feld '${n}' enth\xE4lt keine Datei.`,en:`View: the field '${n}' holds no file.`}}}s(CY,"fieldIssue");function DY(e,n,t){let r=[];Rw.includes(e.key)&&r.push({severity:"error",path:`${n}.key`,code:"view.reserved-key",message:{de:`Der Ansichtsschl\xFCssel '${e.key}' ist f\xFCr die Standardansicht reserviert.`,en:`The view key '${e.key}' is reserved for the standard view.`}});let i=e.groups;i.length===0&&r.push({severity:"error",path:`${n}.groups`,code:"view.empty",message:{de:`Ansicht '${e.key}' hat keine Gruppen.`,en:`View '${e.key}' has no groups.`}}),r.push(...JN(i.map(a=>a.key),{de:`Gruppe der Ansicht '${e.key}'`,en:`Group of view '${e.key}'`},a=>`${n}.groups[${a}]`));let o=new Set;return i.forEach((a,l)=>{let d=`${n}.groups[${l}]`,c=a.fields;c.length===0&&r.push({severity:"error",path:`${d}.fields`,code:"view.empty",message:{de:`Gruppe '${a.key}' der Ansicht '${e.key}' hat keine Felder.`,en:`Group '${a.key}' of view '${e.key}' has no fields.`}}),c.forEach((u,p)=>{let m=`${d}.fields[${p}]`,y=CY(t.get(u),u,m);y!==null&&r.push(y),o.has(u)&&r.push({severity:"error",path:m,code:"view.field-twice",message:{de:`Ansicht '${e.key}': Das Feld '${u}' steht mehrfach; eine Datei hat einen Platz.`,en:`View '${e.key}': the field '${u}' is listed more than once; a file has one place.`}}),o.add(u)})}),r}s(DY,"viewIssues");function FY(e){if(!Array.isArray(e))return"views";for(let[n,t]of e.entries()){let r=t?.groups;if(!Array.isArray(r))return`views[${n}].groups`;for(let[i,o]of r.entries()){let a=o?.fields;if(!Array.isArray(a)||a.some(l=>typeof l!="string"))return`views[${n}].groups[${i}].fields`}}return null}s(FY,"malformedAt");function QN(e){let n=e.views;if(n===void 0)return[];let t=FY(n);if(t!==null)return[{severity:"error",path:t,code:"view.malformed",message:{de:`${t} hat nicht die Form einer Ansicht: views ist eine Liste von { key, label, groups }, groups eine Liste von { key, label, fields }, fields eine Liste von Feldschl\xFCsseln.`,en:`${t} is not shaped like a view: views is a list of { key, label, groups }, groups a list of { key, label, fields }, fields a list of field keys.`}}];let r=_Y(e);return[...JN(n.map(i=>i.key),{de:"Ansicht",en:"View"},i=>`views[${i}]`),...n.flatMap((i,o)=>DY(i,`views[${o}]`,r))]}s(QN,"formViewIssues");function sp(e,n){return{layer:"GRAPH",kind:"nodeRule",path:e,reason:n,severity:"error"}}s(sp,"issue");function ZN(e,n,t,r){let i=e;if(i===null||typeof i!="object"||typeof i.form!="string"||typeof i.key!="string")return[sp(n,{de:`[workItems/formViewInvalid] 'formView' auf ${t.de} muss { form: <Formularknoten>, key: <Ansicht> } sein.`,en:`[workItems/formViewInvalid] 'formView' on ${t.en} must be { form: <form node>, key: <view> }.`})];let o=r?.formViewKeysByFormNode;if(o===void 0)return[];let a=o.get(i.form);return a===void 0?[sp(n,{de:`[workItems/formViewUnknownForm] ${t.de} nennt das Formular "${i.form}", aber kein Formularknoten hei\xDFt so.`,en:`[workItems/formViewUnknownForm] ${t.en} names the form "${i.form}", but no form node has that id.`})]:a.has(i.key)||Rw.includes(i.key)?[]:[sp(n,{de:`[workItems/formViewUnknown] ${t.de} nennt die Ansicht "${i.key}", aber das Formular "${i.form}" hat keine solche Ansicht.`,en:`[workItems/formViewUnknown] ${t.en} names the view "${i.key}", but the form "${i.form}" has no such view.`})]}s(ZN,"viewIssues");function XN(e,n){let t=[];for(let r of e.nodes){if(r.formView!==void 0){let i={de:`Knoten "${r.id}"`,en:`node "${r.id}"`};r.type!=="decision"?t.push(sp(`nodes.${r.id}.formView`,{de:`[workItems/formViewInvalid] ${i.de}: 'formView' am Knoten gilt nur f\xFCr eine Entscheidung; eine Aufgabe tr\xE4gt ihre eigene.`,en:`[workItems/formViewInvalid] ${i.en}: 'formView' on a node applies to a decision only; a task carries its own.`})):t.push(...ZN(r.formView,`nodes.${r.id}.formView`,i,n))}for(let i of Array.isArray(r.tasks)?r.tasks:[]){if(i.formView===void 0)continue;let o=String(i.key);t.push(...ZN(i.formView,`nodes.${r.id}.tasks.${o}.formView`,{de:`Task "${o}" (Knoten "${r.id}")`,en:`Task "${o}" (node "${r.id}")`},n))}}return t}s(XN,"checkTaskFormViews");var _t="traeger",e_={de:"Tr\xE4ger",en:"Provider"};function Xs(e){let n=e.inputs?.[_t];return n?.kind==="literal"&&typeof n.value=="string"&&n.value.length>0?n.value:null}s(Xs,"traegerKeyOfNode");var ap={name:"input.traeger.name",address:"input.traeger.anschrift"},mhe=Object.values(ap);var n_="governedDocument",To="prepareDocument",Ml="prepareDocument:revision",qr="releaseApproval",$o="documentResponse",Kr="responseCheck",lp="returnSigned";var t_="requestApproval";var r_="issueDocument",i_="correctInPlace",o_="rescindAndReissue",dp="requestChange";var ea="releaseArtifact",ut="signingRecovery",cp="resendESignature",Ro="switchToPaper";var Iw=new Set([To,Ml]),s_=["pending","producing","producingHeld","deferred","awaitingApproval","awaitingResponse","responseReturned","responseInCheck","awaitingSignature","signatureStalled","done"],up=["upload","resolver","template","none"],Io=1,Oo=366,di="responseDueInDays";function Ow(e){let n=e.inputs?.[di];return n?.kind==="literal"&&ql(n.value)?n.value:void 0}s(Ow,"responseDueInDaysForVocabulary");function ql(e){return typeof e=="number"&&Number.isInteger(e)&&e>=Io&&e<=Oo}s(ql,"isValidResponseDueInDays");var fp=["generatedAt","responseDueInDays","countersignature"],Po=["release","none"],pp=["confirm","signedUpload","signedUploadChecked","eSignature"];var LY={kind:"confirm",acceptOutcomeId:"accepted",declineOutcomeId:"declined",outcomeSemantics:{accept:"granted",decline:"rejected"},acceptEvent:"userTaskResolved",producesResponseArtifact:!1,declineIsAnswer:!0,acceptStatus:"accepted",checksReturn:!1,issuesBy:"paper",defaultLabels:{accept:{de:"Annehmen",en:"Accept"},decline:{de:"Ablehnen",en:"Decline"}}},a_={kind:"signedUpload",acceptOutcomeId:"signed",declineOutcomeId:"absage",outcomeSemantics:{accept:"other",decline:"rejected"},acceptEvent:"userTaskResolved",producesResponseArtifact:!0,declineIsAnswer:!1,acceptStatus:"signed",checksReturn:!1,issuesBy:"paper",defaultLabels:{accept:{de:"Unterschrieben zur\xFCcksenden",en:"Return signed"},decline:{de:"Ablehnen",en:"Decline"}}},l_={...a_,kind:"signedUploadChecked",acceptEvent:"contractEvent",checksReturn:!0},MY={...l_,kind:"eSignature",issuesBy:"provider"},ci={confirm:LY,signedUpload:a_,signedUploadChecked:l_,eSignature:MY};function Bi(e){let n=e.responseStrategy;if(typeof n=="string"&&n in ci)return ci[n];F(`governedDocument node "${e.id}" declares no valid responseStrategy (got ${JSON.stringify(n)}) \u2014 publish validation should have blocked this; corrupt pinned graph`)}s(Bi,"responseStrategyOf");function mp(e){if(e.type!==n_||e.production!=="resolver")return!1;let n=e.responseStrategy;return typeof n=="string"&&n in ci?ci[n].acceptEvent==="contractEvent":!1}s(mp,"isFamilySignedContractNode");function Kl(e){return e.label}s(Kl,"governedDocTitle");function Pw(e){return e.approval==="release"?t_:r_}s(Pw,"submitActionId");function d_(e,n,t){return{key:n,recipient:"internal",title:t,unlocks:[Pw(e)],gatesNode:!0,advancesNode:!0}}s(d_,"producerTemplate");function qY(e){return e.titles?.respond??e.label}s(qY,"responseTitle");var na={de:"\u27E8Titel fehlt\u27E9",en:"\u27E8title missing\u27E9"};function Nw(e){let n=Bi(e),t=[];if(e.production!=="none"&&t.push(d_(e,To,e.titles?.prepare??na),d_(e,Ml,e.titles?.revise??na)),e.approval==="release"&&t.push({key:qr,recipient:"internal",title:e.titles?.approve??na,unlocks:[],verdictResolved:!0,gatesNode:!0,advancesNode:!0}),t.push({key:$o,recipient:"external",title:qY(e),unlocks:n.producesResponseArtifact?[n.checksReturn?lp:n.acceptOutcomeId,n.declineOutcomeId,dp]:[n.acceptOutcomeId,n.declineOutcomeId],advancesNode:!0,...Ow(e)!==void 0?{dueInDays:Ow(e)}:{}}),n.checksReturn&&t.push({key:Kr,recipient:"internal",title:e.titles?.check??na,unlocks:[],verdictResolved:!0,gatesNode:!1,advancesNode:!0}),n.issuesBy==="provider"){let r=Kl(e);t.push({key:ut,recipient:"internal",title:{de:`${r.de}: elektronische Unterschrift kl\xE4ren`,en:`${r.en}: resolve the e-signature`},unlocks:[cp,Ro],gatesNode:!1,advancesNode:!1})}return t}s(Nw,"governedDocIntrinsicTemplates");function KY(e){e.production==="none"&&F(`governedDocSlot: node "${e.id}" has production 'none' \u2014 it governs no artifact slot`);let n=e.artifacts??[];n.length!==1&&F(`governedDocSlot: node "${e.id}" declares ${n.length} artifact slots \u2014 exactly ONE is required (publish validation [governedDocument/slotContract])`);let t=n[0];return(typeof t.key!="string"||t.key.length===0)&&F(`governedDocSlot: node "${e.id}" declares an artifact slot without a key \u2014 corrupt pinned graph`),t}s(KY,"governedDocSlot");function hp(e){return KY(e).key}s(hp,"governedDocSlotKey");var kr="processFooter";var gp="countersign",_w="countersign",c_="countersigned",u_="countersigning",f_="countersigned";var p_={de:"Vertrag gegenzeichnen",en:"Countersign the contract"},jl=["scan","eSignature"],yp="service_provider:1",m_=["countersigning","awaitingSignature","signatureStalled","done"],h_={de:"Elektronische Gegenzeichnung kl\xE4ren",en:"Resolve the electronic countersignature"};function g_(e){return{de:`[countersign/traegerSignatoryMissing] Die Schule zeichnet elektronisch gegen, aber f\xFCr ${e} ist keine Unterschriftsperson hinterlegt, die unterschreiben kann (Rechtstr\xE4ger \u2192 signatoryUserKey, aktives Personal der Schule).`,en:`[countersign/traegerSignatoryMissing] The school countersigns electronically, but no signatory who can sign is on file for ${e} (legal entity \u2192 signatoryUserKey, active staff of the school).`}}s(g_,"traegerSignatoryMissingReason");function Zt(e,n,t){return{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${n}`,reason:t,severity:"error"}}s(Zt,"issue");function wp(e,n){return e.nodes.filter(t=>{let r=t.contract;return t.type==="countersign"&&we(r)&&r.scope==="node"&&r.owner===n})}s(wp,"countersignersOf");function Bl(e){return e.signing==="eSignature"}s(Bl,"isElectronic");function jY(e,n){if(n===void 0||n.sendable||!Bl(e))return[];let t=e.label?.de??e.id,r=e.label?.en||e.id;return[Zt(e,"signing",{de:`[countersign/eSignatureNeedsProvider] \u201E${t}\u201C zeichnet elektronisch gegen, aber die Schule kann nicht senden: ${n.reason.de}`,en:`[countersign/eSignatureNeedsProvider] "${r}" countersigns electronically, but the school cannot send: ${n.reason.en}`})]}s(jY,"countersignProviderIssues");function BY(e,n,t){if(t.scope!=="node")return[];let r=e.nodes.find(o=>o.id===t.owner);if(r===void 0)return[];let i=[];return mp(r)||i.push("sourceNotCheckedContract"),wp(e,r.id).some(o=>o.id!==n)&&i.push("twice"),i}s(BY,"countersignContractRefusals");function y_(e){let n=e.inputs?.dueInDays;return n?.kind==="literal"&&typeof n.value=="number"&&Number.isInteger(n.value)&&n.value>=1?n.value:void 0}s(y_,"validDueInDays");function VY(e,n,t){let r=e.label?.de??e.id,i=e.label?.en||e.id,o=e.signing;if(o!==void 0&&!jl.includes(o))return[Zt(e,"signing",{de:`[countersign/unknownSigning] \u201E${r}\u201C: signing ist scan oder eSignature (gefunden: ${JSON.stringify(o)}).`,en:`[countersign/unknownSigning] "${i}": signing is scan or eSignature (found: ${JSON.stringify(o)}).`})];let a=e.assign?.[ut];if(!Bl(e))return a===void 0?[]:[Zt(e,"assign",{de:`[countersign/recoveryAssign] \u201E${r}\u201C zeichnet auf Papier gegen \u2014 \`assign.signingRecovery\` h\xE4lt keine Aufgabe und geh\xF6rt entfernt.`,en:`[countersign/recoveryAssign] "${i}" countersigns on paper \u2014 \`assign.signingRecovery\` holds no task and must be removed.`})];let l=[];return(typeof a!="string"||a.length===0)&&l.push(Zt(e,"assign",{de:`[countersign/recoveryAssign] \u201E${r}\u201C zeichnet elektronisch gegen \u2014 wer eine gescheiterte Gegenzeichnung kl\xE4rt, fehlt: \`assign.signingRecovery\` nennt das Team.`,en:`[countersign/recoveryAssign] "${i}" countersigns electronically \u2014 who resolves a failed countersignature is missing: \`assign.signingRecovery\` names the team.`})),l.push(...UY(e,n,t),...GY(e,n,t),...jY(e,t?.signingProvider)),l}s(VY,"signingIssues");function k_(e,n){let t=e.contract;if(!(!we(t)||t.scope!=="node"))return n.nodes.find(r=>r.id===t.owner)}s(k_,"contractNodeOf");function UY(e,n,t){let r=k_(e,n),i=r===void 0?null:Xs(r),o=i===null?void 0:t?.traeger?.get(i);return o===void 0||o.hasSignatory?[]:[Zt(e,"signing",g_(o.name))]}s(UY,"traegerSignatoryIssues");function GY(e,n,t){let r=k_(e,n);if(r===void 0)return[];let i=t?.resolverDocumentAnchors?.get(r.id);if(i===void 0)return[];let o=e.label?.de??e.id,a=e.label?.en||e.id,l=[];for(let d of i)d.documentAnchors===null?l.push(Zt(e,"signing",{de:`[countersign/eSignatureAnchorMissing] \u201E${o}\u201C zeichnet elektronisch gegen, aber die Vorlage des Generators \u201E${d.pin}\u201C wurde nie auf Unterschriftsanker gelesen \u2014 Vorlage neu hochladen und den Generator neu versiegeln.`,en:`[countersign/eSignatureAnchorMissing] "${a}" countersigns electronically, but the template of generator "${d.pin}" was never read for signature anchors \u2014 upload the template again and seal the generator again.`})):d.documentAnchors.has(yp)||l.push(Zt(e,"signing",{de:`[countersign/eSignatureAnchorMissing] \u201E${o}\u201C zeichnet elektronisch gegen, aber die Vorlage von \u201E${d.pin}\u201C tr\xE4gt keinen Anker /unterschrift:${yp}/ \u2014 der Anbieter f\xE4nde f\xFCr die Schule kein Unterschriftsfeld.`,en:`[countersign/eSignatureAnchorMissing] "${a}" countersigns electronically, but the template of "${d.pin}" carries no anchor /unterschrift:${yp}/ \u2014 the provider would find no signature field for the school.`}));return l}s(GY,"traegerAnchorIssues");var Cw=100;async function zY(e,n){let t=await e.db.query("work_items").withIndex("by_applicationId_and_nodeId",o=>o.eq("context.applicationId",n.applicationId).eq("context.anchor.nodeId",n.node.id)).take(Cw+1);t.length>Cw&&F(`countersign node "${n.node.id}" of ${n.applicationId} holds more than ${Cw} rows`);let r=t.filter(o=>o.isOpen),i=s(o=>{if(o.context.kind!=="admission")return;let a=o.context.anchor;return"templateKey"in a?a.templateKey:void 0},"templateKeyOf");return r.some(o=>i(o)===ut)?"signatureStalled":r.some(o=>i(o)===gp)?"countersigning":Bl(n.node)?"awaitingSignature":"done"}s(zY,"countersignCurrentState");var w_={[u_]:{label:te("Gegenzeichnung","Countersignature"),tone:"teal",phase:{key:"gegenzeichnung",label:te("Gegenzeichnung","Countersignature"),scope:"node"},external:en(te("Vertrag unterschrieben","Contract signed"),"blue",te("Die Schule zeichnet Ihren Vertrag gegen","The school is countersigning your contract"),te("Vielen Dank f\xFCr Ihre Unterschrift. Sobald die Schule gegengezeichnet hat, finden Sie Ihr Exemplar hier.","Thank you for signing. As soon as the school has countersigned, you will find your copy here."))}},b_={inputs:s(()=>[{id:"dueInDays",label:{de:"Frist der Aufgabe (Tage)",en:"Task due in (days)"},type:"number",inspector:"literal-only"}],"inputs"),role:"user-action",effect:"side-effect",outcomes:[{id:c_,label:{de:"Gegengezeichnet",en:"Countersigned"}}],progressDefaults:w_,progressEvents:Mn(w_),notificationEvents:s(()=>[{id:f_,label:{de:"Vertrag gegengezeichnet",en:"Contract countersigned"},audience:"external",required:!0,args:[{key:"applicationId",type:"string",required:!0},{key:"documentTitle",type:"localizedText",required:!0}]}],"notificationEvents"),actions:s(e=>[{id:_w,kind:"internal",label:p_,surface:kr,availableIn:["countersigning"]},...Bl(e)?[{id:Ro,kind:"internal",surface:kr,label:{de:"Auf Papier umstellen",en:"Switch to paper"},availableIn:["signatureStalled"]}]:[]],"actions"),workItemTemplates:s(e=>[{key:gp,recipient:"internal",title:e.titles?.countersign??na,unlocks:[_w],advancesNode:!0,...y_(e)!==void 0?{dueInDays:y_(e)}:{}},...Bl(e)?[{key:ut,recipient:"internal",title:h_,unlocks:[Ro],gatesNode:!1,advancesNode:!1}]:[]],"workItemTemplates"),states:m_,currentState:zY,validate:s((e,n,t)=>{let r=[],i=e.label?.de??e.id,o=e.label?.en||e.id,a=e.assign?.[gp];(typeof a!="string"||a.length===0)&&r.push(Zt(e,"assign",{de:`[countersign/assign] \u201E${i}": wer gegenzeichnet, fehlt \u2014 \`assign.countersign\` nennt das Team.`,en:`[countersign/assign] "${o}": who countersigns is missing \u2014 \`assign.countersign\` names the team.`})),$i(e.titles?.countersign)||r.push(Zt(e,"titles",{de:`[countersign/missingTitle] \u201E${i}": der Titel der Aufgabe fehlt \u2014 \`titles.countersign\` auf Deutsch und Englisch.`,en:`[countersign/missingTitle] "${o}": the task title is missing \u2014 \`titles.countersign\` in German and English.`}));let l=e.inputs?.dueInDays;l!==void 0&&l.kind!=="unset"&&!(l.kind==="literal"&&typeof l.value=="number"&&Number.isInteger(l.value)&&l.value>=1)&&r.push(Zt(e,"inputs.dueInDays",{de:`[countersign/dueInDays] \u201E${i}": dueInDays ist eine ganze Zahl \u2265 1.`,en:`[countersign/dueInDays] "${o}": dueInDays is a whole number \u2265 1.`})),r.push(...VY(e,n,t));let d=e.contract;if(!we(d))return r;let c=BY(n,e.id,d);if(c.length===0)return r;let u=n.nodes.find(p=>d.scope==="node"&&p.id===d.owner);if(c.includes("sourceNotCheckedContract")&&r.push(Zt(e,"contract",{de:`[countersign/sourceNotCheckedContract] \u201E${i}" zeichnet das Dokument von \u201E${u.label?.de??u.id}" (${u.id}) gegen \u2014 gegenzeichnen l\xE4sst sich nur ein erzeugter Vertrag, den die Familie mit verbuchten Unterschriften unterschreibt (governedDocument mit production: resolver und responseStrategy: signedUploadChecked oder eSignature).`,en:`[countersign/sourceNotCheckedContract] "${o}" countersigns the document of "${u.label?.en||u.id}" (${u.id}) \u2014 only a generated contract that the family signs with booked signatures can be countersigned (governedDocument with production: resolver and responseStrategy: signedUploadChecked or eSignature).`})),c.includes("twice")){let p=wp(n,u.id).filter(m=>m.id!==e.id);r.push(Zt(e,"contract",{de:`[countersign/twice] \u201E${i}": \u201E${u.label?.de??u.id}" (${u.id}) wird schon von ${p.map(m=>`"${m.id}"`).join(", ")} gegengezeichnet \u2014 ein Vertrag hat eine Gegenzeichnung.`,en:`[countersign/twice] "${o}": "${u.label?.en||u.id}" (${u.id}) is already countersigned by ${p.map(m=>`"${m.id}"`).join(", ")} \u2014 a contract has one countersignature.`}))}return r},"validate")};function WY(e){return mp(e)?Xs(e):null}s(WY,"traegerSignerOf");var YY=s(e=>e.type==="end"&&So(e)==="approved","isApprovedEnd");function v_(e){let n=[];for(let t of e.nodes){let r=WY(t);if(r===null)continue;let i=wp(e,t.id).map(u=>u.id),o=qO(e,t.id,new Set(i),YY);if(o===null)continue;let a=t.label?.de||t.id,l=t.label?.en||t.id,d={de:`Einen Knoten \u201EUnterschrift (intern)\u201C (countersign) mit contract: $node.${t.id}.contract auf jeden Weg zu einem Ende mit Ergebnis approved setzen.`,en:`Place an "Internal signature" node (countersign) with contract: $node.${t.id}.contract on every path to an end with outcome approved.`},c=i.length===0?{de:`[countersign/missingForContract] \u201E${a}\u201C (${t.id}) erzeugt einen Vertrag, den der Tr\xE4ger \u201E${r}\u201C mitunterschreibt, aber keine Gegenzeichnung nennt ihn \u2014 der Vertrag w\xFCrde nie unterschrieben und nie abgerechnet. ${d.de}`,en:`[countersign/missingForContract] "${l}" (${t.id}) generates a contract the legal entity "${r}" co-signs, but no countersignature names it \u2014 the contract would never be signed and never billed. ${d.en}`}:{de:`[countersign/missingForContract] \u201E${a}\u201C (${t.id}): ein Weg erreicht das Ende \u201E${o}\u201C (Ergebnis approved), ohne durch die Gegenzeichnung ${i.map(u=>`\u201E${u}\u201C`).join(", ")} zu laufen \u2014 dort bliebe der Vertrag ohne Unterschrift des Tr\xE4gers \u201E${r}\u201C und w\xFCrde nie abgerechnet. ${d.de}`,en:`[countersign/missingForContract] "${l}" (${t.id}): a path reaches the end "${o}" (outcome approved) without passing the countersignature ${i.map(u=>`"${u}"`).join(", ")} \u2014 there the contract would lack the signature of the legal entity "${r}" and never be billed. ${d.en}`};n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${t.id}`,reason:c,severity:"error"})}return n}s(v_,"checkCountersignCoverage");function HY(e){let n="error",t=new Map;for(let a of Qt(e.nodes)){let l=t.get(a.source)??[];l.push({id:a.id,target:a.target}),t.set(a.source,l)}let r=[],i=new Set,o=Xf(e.nodes.map(a=>a.id),a=>(t.get(a)??[]).map(({id:l,target:d})=>({target:d,edge:l})));for(let a of o)i.has(a.edge)||(i.add(a.edge),r.push({layer:"GRAPH",kind:"cycle",path:`edge.${a.edge}`,reason:{de:`Zyklus \xFCber Kante ${a.source} \u2192 ${a.target}`,en:`Cycle through edge ${a.source} \u2192 ${a.target}`},severity:n}));return r}s(HY,"checkAcyclic");function JY(e){let n=[],t=new Set(e.nodes.map(i=>i.id)),r="error";for(let i of e.nodes){let o=i.next;if(o)for(let[a,l]of Object.entries(o))t.has(l.to)||n.push({layer:"GRAPH",kind:"routing",path:`node.${i.id}.next.${a}`,reason:{de:`${i.label.de}: next.${a} verweist auf nicht-existenten Knoten '${l.to}'`,en:`${i.label.en}: next.${a} points to a node that does not exist: '${l.to}'`},severity:"error"});if(i.type!=="end"&&!(!i.outcomes||i.outcomes.length===0))for(let a of i.outcomes)(!o||!(a.id in o))&&n.push({layer:"GRAPH",kind:"routing",path:`node.${i.id}.outcome.${a.id}`,reason:{de:`${i.label.de}: Outcome '${a.label.de}' fehlt im next-Mapping`,en:`${i.label.en}: outcome '${a.label.en}' is missing from the next mapping`},severity:r})}return n}s(JY,"checkNextTargets");function QY(e){let n=[];for(let t of e.nodes){let r=t.next;if(!r)continue;let i=Hy(t),o=new Set(i?i.map(a=>a.id):[Bs]);for(let a of Object.keys(r))o.has(a)||n.push({layer:"GRAPH",kind:"unknownOutcome",path:`node.${t.id}.next.${a}`,reason:{de:`${t.label.de}: next-Schl\xFCssel '${a}' ist kein g\xFCltiges Outcome dieses Knotens (erlaubt: ${[...o].join(", ")}) \u2014 die Kante w\xFCrde im Editor verschwinden`,en:`${t.label.en}: next key '${a}' is not a valid outcome of this node (allowed: ${[...o].join(", ")}) \u2014 the edge would disappear in the editor`},severity:"error"})}return n}s(QY,"checkNextOutcomesKnown");function ZY(e){let n=[],t=new Set(Qt(e.nodes).map(o=>o.target)),r=e.nodes.filter(o=>!t.has(o.id));return r.length===0?n.push({layer:"GRAPH",kind:"startEnd",path:"graph",reason:{de:"Kein Start-Knoten",en:"No start node"},severity:"error"}):r.length>1&&n.push({layer:"GRAPH",kind:"startEnd",path:"graph",reason:{de:`Mehrere Start-Knoten (${r.map(o=>o.label.de).join(", ")})`,en:`Multiple start nodes (${r.map(o=>o.label.en).join(", ")})`},severity:"warning"}),e.nodes.filter(o=>o.type==="end").length===0&&n.push({layer:"GRAPH",kind:"startEnd",path:"graph",reason:{de:"Kein End-Knoten",en:"No end node"},severity:"warning"}),n}s(ZY,"checkStartEnd");function XY(e){let n=new Map;for(let r of Qt(e.nodes))n.set(r.source,(n.get(r.source)??0)+1);let t=[];for(let r of e.nodes)r.type!=="end"&&(n.get(r.id)??0)===0&&t.push({layer:"GRAPH",kind:"startEnd",path:`node.${r.id}`,reason:{de:`${r.label.de}: keine ausgehende Kante`,en:`${r.label.en}: no outgoing edge`},severity:"warning"});return t}s(XY,"checkNoOutgoingEdge");function eH(e){return e.nodes.filter(n=>!Jg(n.id)).map(n=>({layer:"GRAPH",kind:"nodeRule",path:`nodes.${n.id}.id`,reason:{de:`[graph/nodeIdFormat] Knoten "${n.id}": eine Knoten-ID ist ein Bezeichner ohne Punkt (${fr.source}), z. B. "reviewEingereicht". Ein Bundle von vor der Umstellung neu exportieren.`,en:`[graph/nodeIdFormat] Node "${n.id}": a node id is an identifier without a dot (${fr.source}), e.g. "reviewSubmitted". Export a bundle from before the change again.`},severity:"error"}))}s(eH,"checkNodeIdFormat");function nH(e){let n=new Set(e.nodes.map(r=>r.id)),t=[];for(let r of Qt(e.nodes))n.has(r.source)||t.push({layer:"GRAPH",kind:"startEnd",path:`edge.${r.id}`,reason:{de:`Kante ${r.id}: Quelle '${r.source}' nicht gefunden`,en:`Edge ${r.id}: source '${r.source}' not found`},severity:"error"}),n.has(r.target)||t.push({layer:"GRAPH",kind:"startEnd",path:`edge.${r.id}`,reason:{de:`Kante ${r.id}: Ziel '${r.target}' nicht gefunden`,en:`Edge ${r.id}: target '${r.target}' not found`},severity:"error"});return t}s(nH,"checkEdgeEndpoints");var tH=new Set(["countersignature"]);function rH(e){let n=[],t=s((r,i)=>{n.push({layer:"GRAPH",kind:"nodeRule",path:r,reason:{de:`[graph/retiredField] ${i.de}`,en:`[graph/retiredField] ${i.en}`},severity:"error"})},"retired");for(let r of e.nodes){let i=r,o={de:`Knoten \u201E${Oe(e,r.id,"de")}\u201C (${r.id})`,en:`Node "${Oe(e,r.id,"en")}" (${r.id})`};for(let[l,d]of Object.entries(i.next??{}))d!==null&&typeof d=="object"&&"emits"in d&&t(`nodes.${r.id}.next.${l}.emits`,{de:`${o.de}: \`next.${l}.emits\` gibt es nicht mehr \u2014 ein Ausgang routet nur; ein Knoten liest Daten \xFCber Adressen in seinen eigenen Feldern.`,en:`${o.en}: \`next.${l}.emits\` no longer exists \u2014 an outcome only routes; a node reads data through addresses in its own fields.`});for(let l of Array.isArray(i.outcomes)?i.outcomes:[])l!==null&&typeof l=="object"&&"emits"in l&&t(`nodes.${r.id}.outcomes.${String(l.id)}.emits`,{de:`${o.de}: \`emits\` am Ausgang "${String(l.id)}" gibt es nicht mehr \u2014 ein Knoten liest Daten \xFCber Adressen in seinen eigenen Feldern.`,en:`${o.en}: \`emits\` on the outcome "${String(l.id)}" no longer exists \u2014 a node reads data through addresses in its own fields.`});"targetFormNodeId"in i&&t(`nodes.${r.id}.targetFormNodeId`,{de:`${o.de}: \`targetFormNodeId\` gibt es nicht mehr \u2014 welches Formular freigeschaltet wird, sagt die Adresse, an die der Eingang \`inputs.target\` gebunden ist ($node.<formular>.admission).`,en:`${o.en}: \`targetFormNodeId\` no longer exists \u2014 the address the input \`inputs.target\` is bound to says which form is unlocked ($node.<form>.admission).`}),"wires"in i&&t(`nodes.${r.id}.wires`,{de:`${o.de}: Datenkanten (\`wires\`) gibt es nicht mehr \u2014 jedes Feld, das Daten eines anderen Knotens liest, tr\xE4gt selbst die volle Adresse ($node.\u2026, $task.\u2026, $derived.\u2026, $env.\u2026).`,en:`${o.en}: data edges (\`wires\`) no longer exist \u2014 every field that reads data of another node carries the full address itself ($node.\u2026, $task.\u2026, $derived.\u2026, $env.\u2026).`});for(let[l,d]of Object.entries(i.inputs??{}))d!==null&&typeof d=="object"&&d.kind==="binding"&&"path"in d&&t(`nodes.${r.id}.inputs.${l}.path`,{de:`${o.de}: Der Eingang \u201E${l}\u201C ist \xFCber einen Pfad (\`path\`) gebunden \u2014 eine Bindung tr\xE4gt die volle Adresse (\`address\`) dessen, was sie liest.`,en:`${o.en}: The input "${l}" is bound through a path (\`path\`) \u2014 a binding carries the full address (\`address\`) of what it reads.`});r.type==="governedDocument"&&"resolver"in i&&t(`nodes.${r.id}.resolver`,{de:`${o.de}: \`resolver\` gibt es nicht mehr \u2014 der Generator ist der Eingang \`inputs.contractGenerator\` ({ kind, key }), seine Parameter stempelt die Plattform (\`generatorStamp\`), ein im Cockpit erg\xE4nzter Parameter ist sein Eingang \`{ kind: "cockpit" }\`.`,en:`${o.en}: \`resolver\` no longer exists \u2014 the generator is the input \`inputs.contractGenerator\` ({ kind, key }), the platform stamps its parameters (\`generatorStamp\`), a parameter completed in the cockpit is its input \`{ kind: "cockpit" }\`.`});let a=i.template;if(r.type==="governedDocument"&&a!==null&&typeof a=="object")for(let l of["key","cockpitFields"])l in a&&t(`nodes.${r.id}.template.${l}`,{de:`${o.de}: \`template.${l}\` gibt es nicht mehr \u2014 ${l==="key"?"die Vorlage ist der Eingang `inputs.documentTemplate`":'ein im Cockpit erg\xE4nzter Parameter ist sein Eingang `{ kind: "cockpit" }`'}.`,en:`${o.en}: \`template.${l}\` no longer exists \u2014 ${l==="key"?"the template is the input `inputs.documentTemplate`":'a parameter completed in the cockpit is its input `{ kind: "cockpit" }`'}.`});if(r.type==="setFlag")for(let l of["target","flagKey","value"])l in i&&t(`nodes.${r.id}.${l}`,{de:`${o.de}: \`${l}\` gibt es am setFlag-Knoten nicht mehr \u2014 Formular, Merkmal und Wert sind die Eing\xE4nge \`inputs.target\` (gebunden an die Adresse $node.<formular>.admission), \`inputs.flagKey\` und \`inputs.value\` (feste Werte).`,en:`${o.en}: \`${l}\` no longer exists on a setFlag node \u2014 form, flag and value are the inputs \`inputs.target\` (bound to the address $node.<form>.admission), \`inputs.flagKey\` and \`inputs.value\` (literals).`});for(let l of Object.keys(Py[r.type]??{}))l in i&&t(`nodes.${r.id}.${l}`,{de:`${o.de}: \`${l}\` gibt es als Knoteneigenschaft nicht mehr \u2014 es ist der Eingang \`inputs.${l}\` (ein fester Wert im Parameter-Bereich).`,en:`${o.en}: \`${l}\` no longer exists as a node property \u2014 it is the input \`inputs.${l}\` (a fixed value among the parameters).`});for(let l of Array.isArray(i.tasks)?i.tasks:[]){let d=l?.assign;d===null||typeof d!="object"||!("userId"in d)||t(`nodes.${r.id}.tasks.${String(l.key)}.assign.userId`,{de:`Aufgabe "${String(l.key)}" an ${o.de}: \`assign.userId\` gibt es nicht mehr \u2014 eine Aufgabe nennt ihr Team (\`assign.group\`), nie eine feste Person.`,en:`Task "${String(l.key)}" on ${o.en}: \`assign.userId\` no longer exists \u2014 a task names its team (\`assign.group\`), never a fixed person.`})}for(let l of Ny[r.type]??[])l in i&&t(`nodes.${r.id}.${l}`,{de:`${o.de}: \`${l}\` gibt es nicht mehr \u2014 dieser Knotentyp liest es nicht.`,en:`${o.en}: \`${l}\` no longer exists \u2014 this node type does not read it.`});for(let[l,d]of Object.entries(EO[r.type]??{}))l in i&&t(`nodes.${r.id}.${l}`,{de:`${o.de}: ${d.de}`,en:`${o.en}: ${d.en}`});i.adoptForm===!0&&t(`nodes.${r.id}.adoptForm`,{de:`${o.de}: \`adoptForm: true\` gibt es nicht mehr \u2014 \`adoptForm\` ist die Adresse des \xFCbernommenen Formulars ($node.<anlegender Formularknoten>.admission).`,en:`${o.en}: \`adoptForm: true\` no longer exists \u2014 \`adoptForm\` is the address of the adopted form ($node.<creating form node>.admission).`});for(let l of Array.isArray(i.tasks)?i.tasks:[]){let d=l?.result?.kind;typeof d=="string"&&tH.has(d)&&t(`nodes.${r.id}.tasks.${String(l.key)}.result`,{de:`Aufgabe "${String(l.key)}" an ${o.de}: das Ergebnis \u201E${d}" gibt es nicht mehr \u2014 die Gegenzeichnung ist der Knotentyp \u201EUnterschrift (intern)" (countersign).`,en:`Task "${String(l.key)}" on ${o.en}: the result "${d}" no longer exists \u2014 the countersignature is the node type "Signature (internal)" (countersign).`})}}return n}s(rH,"checkRetiredDataFields");function ta(e,n){return n?.wiring&&n.layout?{wiring:n.wiring,layout:n.layout}:null}s(ta,"resolveLayoutContext");function iH(e,n){let t=ta(e,n);if(!t)return e.nodes.some(o=>(He(o)?.progressEvents?.length??0)>0)?[{layer:"GRAPH",kind:"progressState",path:"graph.progressWiring",reason:{de:`Graph emittiert Progress-Events, aber (Layout, Wiring) konnte nicht aufgel\xF6st werden (Wiring ${n?.wiring?"vorhanden":"fehlt"}, Layout ${n?.layout?"vorhanden":"fehlt"}) \u2014 der Engine wirft beim Spiegeln zur Laufzeit. Der Workflow-Entwurf muss progressLayout und progressWiring tragen.`,en:`The graph emits progress events, but (layout, wiring) could not be resolved (wiring ${n?.wiring?"present":"missing"}, layout ${n?.layout?"present":"missing"}) \u2014 the engine throws at runtime when mirroring. The workflow draft must carry progressLayout and progressWiring.`},severity:"error"}]:[];let r=[];for(let i of e.nodes){let a=He(i)?.progressEvents;if(a)for(let l of a){let d=Ls(t.wiring,{id:i.id,type:i.type},l);if(!d){r.push({layer:"GRAPH",kind:"progressState",path:`node.${i.id}.progressEvents.${l}`,reason:{de:`${i.type} '${i.id}': Progress-Event '${l}' ist im Wiring (Layout '${t.layout.id}') keinem (Bus, State) zugeordnet \u2014 der Engine wirft beim Spiegeln`,en:`${i.type} '${i.id}': progress event '${l}' is not mapped to any (bus, state) in the wiring (layout '${t.layout.id}') \u2014 the engine throws when mirroring`},severity:"error"});continue}let c;try{c=_f(t.layout,d.bus)}catch{r.push({layer:"GRAPH",kind:"progressState",path:`node.${i.id}.progressEvents.${l}`,reason:{de:`${i.type} '${i.id}': Event '${l}' verweist auf unbekannten Bus '${d.bus}' im Layout '${t.layout.id}'`,en:`${i.type} '${i.id}': event '${l}' points to unknown bus '${d.bus}' in layout '${t.layout.id}'`},severity:"error"});continue}Al(c,d.state)||r.push({layer:"GRAPH",kind:"progressState",path:`node.${i.id}.progressEvents.${l}`,reason:{de:`${i.type} '${i.id}': Event '${l}' verweist auf State '${d.state}', der nicht im Bus '${d.bus}' deklariert ist`,en:`${i.type} '${i.id}': event '${l}' points to state '${d.state}', which is not declared in bus '${d.bus}'`},severity:"error"})}}return r}s(iH,"checkProgressEventMappings");function oH(e,n){let t=ta(e,n);if(!t)return[];let r=[];for(let i of t.layout.buses){if(!i.boards||i.boards.length===0)continue;let o=new Set(i.unboarded??[]),a=new Set;for(let l of i.boards)for(let d of l.columns)for(let c of d.states)a.add(c),Al(i,c)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.board.${l.id}.column.${d.id}.${c}`,reason:{de:`Board '${l.id}', Spalte '${d.id}' referenziert State '${c}', der nicht im Bus '${i.key}' deklariert ist`,en:`Board '${l.id}', column '${d.id}' references state '${c}', which is not declared in bus '${i.key}'`},severity:"error"});for(let l of i.states)a.has(l.id)||o.has(l.id)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.${l.id}`,reason:{de:`State '${l.id}' (${l.label.de}) erscheint in keiner Board-Spalte und nicht in 'unboarded' \u2014 nicht darstellbar`,en:`State '${l.id}' (${l.label.en}) appears in no board column and not in 'unboarded' \u2014 it cannot be displayed`},severity:"error"})}return r}s(oH,"checkProgressBoardCoverage");function sH(e,n){let t=ta(e,n);if(!t)return[];let r=[];for(let i of t.layout.buses)if(!(!i.boards||i.boards.length===0))for(let o of i.boards)for(let a of We){let l=new Map;for(let d of o.columns){if(!$i(d.label))continue;let c=d.label[a],u=c.trim().toLocaleLowerCase(a),p=l.get(u);if(p===void 0){l.set(u,d.id);continue}r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.board.${o.id}.column.${d.id}.label.${a}`,reason:{de:`Board '${o.id}' hat zwei Spalten mit dem Label '${c}' (${a}) ('${p}' und '${d.id}') \u2014 f\xFCr Lesende nicht unterscheidbar. F\xFChre die Spalten zusammen (states beider in EINE Spalte) oder vergib unterschiedliche Labels.`,en:`Board '${o.id}' has two columns with the label '${c}' (${a}) ('${p}' and '${d.id}') \u2014 readers cannot tell them apart. Merge the columns (put the states of both into ONE column) or give them different labels.`},severity:"error"})}}return r}s(sH,"checkProgressBoardDistinctLabels");function aH(e,n){let t=ta(e,n);if(!t)return[];let r=[];for(let i of t.layout.buses)for(let o of i.states){let a=Cf(i,o.id);o.terminal&&!a&&r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.${o.id}.terminalSemantics`,reason:{de:`Terminal-State '${o.id}' hat keine Terminal-Semantik im Bus '${i.key}' \u2014 der Engine wirft beim Versiegeln`,en:`Terminal state '${o.id}' has no terminal semantics in bus '${i.key}' \u2014 the engine throws when sealing`},severity:"error"}),!o.terminal&&a&&r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.${o.id}.terminalSemantics`,reason:{de:`State '${o.id}' ist nicht terminal, hat aber Terminal-Semantik im Bus '${i.key}' \u2014 Inkonsistenz`,en:`State '${o.id}' is not terminal but has terminal semantics in bus '${i.key}' \u2014 inconsistent`},severity:"error"})}return r}s(aH,"checkProgressTerminalSemantics");function lH(e,n){let t=ta(e,n);if(!t)return[];let r=[];for(let i of t.layout.buses){let o=new Set(i.holdsSeat??[]);for(let a of i.holdsSeat??[])Al(i,a)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.holdsSeat.${a}`,reason:{de:`holdsSeat referenziert '${a}', das kein State im Bus '${i.key}' ist`,en:`holdsSeat references '${a}', which is not a state in bus '${i.key}'`},severity:"error"});for(let a of i.commitsSeat??[])Al(i,a)?o.has(a)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.commitsSeat.${a}`,reason:{de:`commitsSeat '${a}' ist nicht in holdsSeat \u2014 ein fest belegter Platz muss auch belegt sein`,en:`commitsSeat '${a}' is not in holdsSeat \u2014 a firmly committed seat must also be held`},severity:"error"}):r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.commitsSeat.${a}`,reason:{de:`commitsSeat referenziert '${a}', das kein State im Bus '${i.key}' ist`,en:`commitsSeat references '${a}', which is not a state in bus '${i.key}'`},severity:"error"});for(let[a,l]of Object.entries(i.terminalSemantics??{}))l.outcome==="approved"&&(o.has(a)||r.push({layer:"GRAPH",kind:"progressState",path:`layout.${t.layout.id}.bus.${i.key}.holdsSeat`,reason:{de:`Endzustand '${a}' schlie\xDFt den Prozess positiv ab (outcome 'approved'), steht aber nicht in holdsSeat \u2014 damit z\xE4hlt er als Absage und f\xE4llt aus dem Fortschrittsbalken. Nimm '${a}' in holdsSeat (und in commitsSeat, wenn der Platz damit wirklich belegt ist) auf.`,en:`Final state '${a}' ends the process positively (outcome 'approved'), but is not in holdsSeat \u2014 so it counts as a rejection and drops out of the progress bar. Add '${a}' to holdsSeat (and to commitsSeat, if the seat is really taken by it).`},severity:"error"}))}return r}s(lH,"checkProgressSeatStates");var kp={de:"Abhilfe: nach dem Formularknoten einen review-Knoten einf\xFCgen und dessen 'reviewing' auf diesen Zustand mappen",en:"Remedy: insert a review node after the form node and map its 'reviewing' to this state"};function dH(e){return e==="both"?{de:`${kp.de} \u2014 die Spalte ist auch der Schritt, den die Familie sieht; den Zustand in die Spalte des Nachfolgers zu legen, n\xE4hme ihr diesen Schritt.`,en:`${kp.en} \u2014 the column is also the step the family sees; moving the state into the successor's column would take that step away from them.`}:{de:`${kp.de}, oder den Zustand in die Spalte des Nachfolgers legen.`,en:`${kp.en}, or move the state into the successor's column.`}}s(dH,"passThroughRemedy");function cH(e,n){let t=ta(e,n);if(!t)return[];let{layout:r,wiring:i}=t;if(!r.buses.some(v=>v.key==="process"))return[];let o=zO(r);if(!o)return[];let a=new Map(e.nodes.map(v=>[v.id,v])),l=s(v=>He(v).progressEvents??[],"eventsOf"),d=s(v=>Object.values(v.next??{}).map(E=>E.to),"routesOf"),c=s((v,E)=>{let A=a.get(v);if(!A||E.has(v))return null;if(l(A).length>0)return[A];if(S_[A.type]!==!1)return null;let I=d(A);if(I.length===0)return null;let _=[];for(let T of I){let b=c(T,new Set([...E,v]));if(!b)return null;_.push(...b)}return _},"firstProgressNodes"),u=s((v,E)=>{let A=[];for(let I of l(v)){let _=Ls(i,v,I);if(!_||_.bus!==E.bus||_.state===E.state)return null;A.push(_.state)}return[...new Set(A)].join("' / '")},"overwrites"),p=s((v,E)=>{let A=d(v);if(A.length===0)return null;let I=[];for(let _ of A){let T=c(_,new Set([v.id]));if(!T)return null;for(let b of T){let R=u(b,E);if(R===null)return null;I.push({de:`'${b.id}' (${b.type}) mit '${R}'`,en:`'${b.id}' (${b.type}) with '${R}'`})}}return[...new Map(I.map(_=>[_.de,_])).values()]},"submitOverwrittenBy"),m=new Map;for(let v of e.nodes)for(let E of l(v)){let A=Ls(i,v,E);if(!A||A.bus!=="process")continue;let I=v.type==="form"&&E===Xu?p(v,A):null,_=I?{de:`'${v.id}'.${E} erreicht ihn, und ${I.map(T=>T.de).join(", ")} \xFCberschreibt ihn in derselben Transaktion`,en:`'${v.id}'.${E} reaches it, and ${I.map(T=>T.en).join(", ")} overwrites it in the same transaction`}:null;m.set(A.state,[...m.get(A.state)??[],_])}let y=_f(r,"process"),k=new Map;for(let[v,E]of m){if(!E.every(I=>I!==null))continue;let A=[...new Map(E.map(I=>[I.de,I])).values()];k.set(v,{de:A.map(I=>I.de).join("; "),en:A.map(I=>I.en).join("; ")})}let g=[];for(let v of o.columns){if(v.states.length===0||!v.states.every(I=>k.has(I)))continue;let E=v.states.map(I=>{let _=y.holdsSeat?.includes(I)===!0,T=k.get(I);return{de:`Zustand '${I}'${_?" (steht in holdsSeat, belegt aber nie einen Platz)":""}: ${T.de}`,en:`State '${I}'${_?" (is in holdsSeat, but never takes a seat)":""}: ${T.en}`}}),A=dH(o.audience);g.push({layer:"GRAPH",kind:"progressState",path:`progressLayout.process.boards.${o.id}.columns.${v.id}`,reason:{de:`[progress/passThroughState] Spalte \u201E${v.label.de}" ('${v.id}', Board '${o.id}') bleibt immer leer \u2014 ${E.map(I=>I.de).join("; ")}. ${A.de}`,en:`[progress/passThroughState] Column "${v.label.en}" ('${v.id}', board '${o.id}') always stays empty \u2014 ${E.map(I=>I.en).join("; ")}. ${A.en}`},severity:"warning"})}return g}s(cH,"checkProgressPassThroughColumns");function uH(e){let n=["workItems","workitems","work_items","taskTemplates"],t=[];for(let r of e.nodes){let i=r;for(let o of n){let a=i[o];a!=null&&t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.${o}`,reason:{de:`[workItems/misnamedTasksKey] Knoten "${r.id}" deklariert "${o}" \u2014 komponierte Aufgaben werden ausschlie\xDFlich unter "tasks" gelesen. So wie es dasteht, w\xFCrde die Aufgabenkette stillschweigend nie entstehen. Benenne den Schl\xFCssel in "tasks" um.`,en:`[workItems/misnamedTasksKey] Node "${r.id}" declares "${o}" \u2014 composed tasks are read only from "tasks". As it stands, the task chain would silently never be created. Rename the key to "tasks".`},severity:"error"})}}return t}s(uH,"checkMisnamedTasksKey");function fH(e){let n=[];for(let t of e.nodes){let r=t,i=Array.isArray(r.tasks)?r.tasks:[],o=new Set;for(let c of i){let u=typeof c.key=="string"?c.key:void 0;u!==void 0&&(o.has(u)&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}`,reason:{de:`[workItems/duplicateTemplateKey] Doppelter Template-Key "${u}" auf Knoten "${r.id}".`,en:`[workItems/duplicateTemplateKey] Duplicate template key "${u}" on node "${r.id}".`},severity:"error"}),o.add(u))}let a=new Set;for(let c of Array.isArray(r.artifacts)?r.artifacts:[])typeof c.key=="string"&&a.add(`${c.key}Uploaded`);let l=He(t),d=new Map((typeof l.workItemTemplates=="function"?l.workItemTemplates(t):[]).map(c=>[c.key,c]));for(let c of i){let u=typeof c.key=="string"?c.key:"?",p=typeof c.kind=="string"?c.kind:void 0;if(p===void 0||!Nl.has(p)){n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.kind`,reason:{de:`[workItems/invalidKind] Task "${u}" auf Knoten "${r.id}" hat Art ${JSON.stringify(c.kind)}; komponierbar sind: ${[...Nl].join(", ")}.`,en:`[workItems/invalidKind] Task "${u}" on node "${r.id}" has kind ${JSON.stringify(c.kind)}; composable kinds are: ${[...Nl].join(", ")}.`},severity:"error"});continue}p==="task"&&c.gatesNode!==void 0&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.gatesNode`,reason:{de:`[workItems/gatesNodeOnTask] 'gatesNode' ist nur f\xFCr die Art 'approval' zul\xE4ssig \u2014 eine Task gated ihren Knoten nie direkt. Um eine gatende Freigabe zur\xFCckzuhalten, 'blocks' verwenden (Task "${u}" auf Knoten "${r.id}").`,en:`[workItems/gatesNodeOnTask] 'gatesNode' is only allowed for the kind 'approval' \u2014 a task never gates its node directly. To hold back a gating approval, use 'blocks' (task "${u}" on node "${r.id}").`},severity:"error"});let m=c.blocks,y=m===void 0?void 0:KN(e,r.id,m.node);if(m!==void 0&&y===null)n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.node`,reason:{de:`[workItems/blocksUnknownNode] 'blocks.node' auf Task "${u}" (Knoten "${r.id}") nennt ${JSON.stringify(m.node)} \u2014 diesen Knoten gibt es im Workflow nicht.`,en:`[workItems/blocksUnknownNode] 'blocks.node' on task "${u}" (node "${r.id}") names ${JSON.stringify(m.node)} \u2014 there is no such node in the workflow.`},severity:"error"});else if(m!==void 0&&y!==void 0&&y!==null){let g=y.node.id===r.id,v=y.node.id,E=g?o:y.composedKeys,A=g?d:y.intrinsicByKey,I=y.node.assign??{};p==="approval"&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks`,reason:{de:`[workItems/blocksOnApproval] 'blocks' ist auf der Art 'approval' verboten \u2014 nur Task-Zeilen d\xFCrfen einen Geschwister-Spawn zur\xFCckhalten (Approval "${u}" auf Knoten "${r.id}").`,en:`[workItems/blocksOnApproval] 'blocks' is forbidden on the kind 'approval' \u2014 only task rows may hold back a sibling spawn (approval "${u}" on node "${r.id}").`},severity:"error"});let _=m.templateKey,T=[...new Set([...E,...A.keys()])].filter(R=>!g||R!==u).join(", "),b={de:T||"keine",en:T||"none"};if(typeof _!="string"||g&&_===u||!E.has(_)&&!A.has(_))n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.templateKey`,reason:{de:`[workItems/blocksUnknownTarget] 'blocks' muss ein Template auf dem Zielknoten benennen \u2014 komponiert ODER intrinsisch (nie sich selbst, nie ohne 'templateKey': die zielfreie Form geh\xF6rt der Maschine, nicht dem Autor). Ziel ${JSON.stringify(_)} auf Knoten "${v}"; zul\xE4ssige Ziele: ${b.de}.`,en:`[workItems/blocksUnknownTarget] 'blocks' must name a template on the target node \u2014 composed OR intrinsic (never itself, never without 'templateKey': the target-less form belongs to the engine, not the author). Target ${JSON.stringify(_)} on node "${v}"; allowed targets: ${b.en}.`},severity:"error"});else if(y.refuse(_)!==null)n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.templateKey`,reason:y.refuse(_),severity:"error"});else{let R=A.get(_);m.except!==void 0&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.except`,reason:{de:`[workItems/blocksExceptRetired] 'blocks.except' auf Task "${u}" (Knoten "${r.id}") gibt es nicht mehr: eine blockierende Aufgabe sperrt die ganze Aktionsgruppe ihres Ziels (bei einer Entscheidung Freigeben, Warteliste, Ablehnen und das Nachr\xFCcken). 'except' entfernen.`,en:`[workItems/blocksExceptRetired] 'blocks.except' on task "${u}" (node "${r.id}") no longer exists: a blocking task locks the whole action group of its target (for a decision: approve, waitlist, reject and promote). Remove 'except'.`},severity:"error"}),R!==void 0&&R.recipient!=="external"&&R.verdictResolved!==!0&&typeof I[_]!="string"&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.blocks.templateKey`,reason:{de:`[workItems/blocksUnwiredTarget] Task "${u}" auf Knoten "${r.id}" h\xE4lt "${_}" (Knoten "${v}") zur\xFCck, aber der Knoten weist "${_}" keiner Gruppe zu \u2014 ohne 'assign.${_}' entsteht diese Zeile nie: kein Team bekommt die zur\xFCckgehaltene Arbeit, niemand au\xDFer der verantwortlichen Person kann sie tun. Entweder 'assign.${_}' erg\xE4nzen oder das 'blocks' entfernen.`,en:`[workItems/blocksUnwiredTarget] Task "${u}" on node "${r.id}" holds back "${_}" (node "${v}"), but the node assigns "${_}" to no group \u2014 without 'assign.${_}' this row is never created: no team receives the held-back work, and nobody except the responsible person can do it. Either add 'assign.${_}' or remove the 'blocks'.`},severity:"error"})}}{let g=c.completableIf;if(typeof g=="string"&&g.trim().length>0){let v=g.trim().replace(/^!/,"").trim();a.has(v)||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.completableIf`,reason:{de:`[workItems/unknownExport] completableIf "${g}" verweist auf unbekannten Node-Export "${v}"; bekannt: ${[...a].join(", ")||"keine"}.`,en:`[workItems/unknownExport] completableIf "${g}" refers to unknown node export "${v}"; known: ${[...a].join(", ")||"none"}.`},severity:"error"})}}let k=c.params;if(k?.commentRequired!==void 0&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.params.commentRequired`,reason:{de:"[workItems/removedParam] 'params.commentRequired' wurde entfernt \u2014 Kommentar-Pflichten werden am Decision-Node ('commentRequired') autorisiert.",en:"[workItems/removedParam] 'params.commentRequired' was removed \u2014 comment requirements are authored on the decision node ('commentRequired')."},severity:"error"}),p!=="approval"){let g=[];k?.onReject!==void 0&&g.push("params.onReject"),k?.revisionGroup!==void 0&&g.push("params.revisionGroup");for(let v of g)n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.${v}`,reason:{de:`[workItems/approvalOnlyField] '${v}' gilt nur f\xFCr die Art 'approval' (Task "${u}" ist '${p}').`,en:`[workItems/approvalOnlyField] '${v}' only applies to the kind 'approval' (task "${u}" is '${p}').`},severity:"error"});continue}k?.onReject!==void 0&&k.onReject!=="spawnRevision"&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.params.onReject`,reason:{de:`[workItems/invalidOnReject] Erwartet 'spawnRevision', erhalten ${JSON.stringify(k.onReject)}.`,en:`[workItems/invalidOnReject] Expected 'spawnRevision', got ${JSON.stringify(k.onReject)}.`},severity:"error"}),k?.onReject==="spawnRevision"&&(typeof k.revisionGroup!="string"||k.revisionGroup.length===0)&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks.${u}.params.revisionGroup`,reason:{de:`[workItems/spawnRevisionNoTarget] Approval "${u}" mit 'params.onReject: spawnRevision' ohne 'params.revisionGroup' \u2014 die \xDCberarbeitung h\xE4tte keine Ziel-Gruppe.`,en:`[workItems/spawnRevisionNoTarget] Approval "${u}" with 'params.onReject: spawnRevision' but no 'params.revisionGroup' \u2014 the revision would have no target group.`},severity:"error"})}}return n.push(...jN(e)),n}s(fH,"checkWorkItemTemplates");var pH=new Set(["complete","approve","reject"]),S_={form:!0,decision:!0,review:!0,waitlist:!0,completenessCheck:!0,collectPayment:!0,eventTrigger:!0,join:!1,roleAssign:!1,setFlag:!1,if:!1,end:!1,countersign:!0,engagePush:!1,governedDocument:!0};function mH(e){let n=[];for(let t of e.nodes){let r=t,i=He(t),o=Array.isArray(r.tasks)?r.tasks.length:0,a=i.workItemTemplates?.(t)??[];if(o+a.length>0){let v=S_[r.type];v===void 0?n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks`,reason:{de:`[workItems/unknownParkSemantics] Knotentyp "${r.type}" hat keine bekannte Park-Semantik \u2014 NODE_TYPE_PARKS in validators.ts erg\xE4nzen.`,en:`[workItems/unknownParkSemantics] Node type "${r.type}" has no known parking semantics \u2014 add it to NODE_TYPE_PARKS in validators.ts.`},severity:"error"}):v||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.tasks`,reason:{de:`[workItems/templatesOnNonParkingNode] Knoten "${r.id}" (Typ "${r.type}") parkt nie \u2014 seine Work-Item-Templates w\xFCrden im selben Dispatch gespawnt und storniert (totes Muster).`,en:`[workItems/templatesOnNonParkingNode] Node "${r.id}" (type "${r.type}") never parks \u2014 its work-item templates would be spawned and cancelled in the same dispatch (dead pattern).`},severity:"error"})}let l=i.actions?.(t)??[];if(l.length===0&&a.length===0)continue;let d=new Map(l.map(v=>[v.id,v]));for(let v of l)pH.has(v.id)&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actions.${v.id}`,reason:{de:`[capability/reservedActionId] Knotentyp "${r.type}" deklariert die Action "${v.id}" \u2014 reserviert f\xFCr den generischen Complete-/Verdict-Pfad (complete, approve, reject); die Spec muss eine andere Action-Id w\xE4hlen.`,en:`[capability/reservedActionId] Node type "${r.type}" declares the action "${v.id}" \u2014 reserved for the generic complete/verdict path (complete, approve, reject); the spec must choose a different action id.`},severity:"error"});let c=new Set(i.states??[lP]);for(let v of l)if(v.availableIn!==void 0)for(let E of v.availableIn)c.has(E)||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actions.${v.id}.availableIn`,reason:{de:`[capability/unknownActionState] Action "${v.id}" auf Knotentyp "${r.type}" ist f\xFCr Zustand "${E}" deklariert \u2014 der Typ kennt nur: ${[...c].join(", ")}.`,en:`[capability/unknownActionState] Action "${v.id}" on node type "${r.type}" is declared for state "${E}" \u2014 the type only knows: ${[...c].join(", ")}.`},severity:"error"});let u=Hy(t),p=new Set(u?u.map(v=>v.id):[Bs]);for(let v of l){if(v.external===void 0)continue;let E=aP(v.external.event),A={de:"hat keine Beschriftung (der Empf\xE4nger bekommt einen leeren Button)",en:"has no label (the recipient would get an empty button)"},I=E?v.kind==="advance"?{de:`ist als "advance" deklariert, l\xF6st den Knoten aber nicht auf (Ereignis "${v.external.event}") \u2014 solche Aktionen sind "internal"`,en:`is declared as "advance", but does not resolve the node (event "${v.external.event}") \u2014 such actions are "internal"`}:v.outcome!==void 0?{de:`nennt das Outcome "${v.outcome}", l\xF6st den Knoten aber nicht auf (Ereignis "${v.external.event}") \u2014 ein Outcome w\xFCrde eine zweite, stille Routing-Vokabel behaupten`,en:`names the outcome "${v.outcome}", but does not resolve the node (event "${v.external.event}") \u2014 an outcome would claim a second, silent routing vocabulary`}:v.label===void 0?A:null:v.kind!=="advance"?{de:`ist als "${v.kind}" deklariert (externe Aktionen l\xF6sen den Knoten auf und m\xFCssen "advance" sein)`,en:`is declared as "${v.kind}" (external actions resolve the node and must be "advance")`}:v.outcome===void 0?{de:"nennt kein Outcome",en:"names no outcome"}:p.has(v.outcome)?v.label===void 0?A:null:{de:`verweist auf das unbekannte Outcome "${v.outcome}" (deklariert: ${[...p].join(", ")||"keine"})`,en:`refers to the unknown outcome "${v.outcome}" (declared: ${[...p].join(", ")||"none"})`};I!==null&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actions.${v.id}.external`,reason:{de:`[capability/externalActionNeedsOutcome] Externe Aktion "${v.id}" auf Knotentyp "${r.type}" ${I.de}.`,en:`[capability/externalActionNeedsOutcome] External action "${v.id}" on node type "${r.type}" ${I.en}.`},severity:"error"})}for(let v of a){let E=v.unlocks;if(E.length===0&&v.verdictResolved!==!0){n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.workItemTemplates.${v.key}.unlocks`,reason:{de:`[capability/emptyUnlocks] Intrinsisches Template "${v.key}" auf Knoten "${r.id}" schaltet keine Action frei (B5).`,en:`[capability/emptyUnlocks] Intrinsic template "${v.key}" on node "${r.id}" unlocks no action (B5).`},severity:"error"});continue}for(let A of E)d.get(A)===void 0&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.workItemTemplates.${v.key}.unlocks`,reason:{de:`[capability/danglingUnlock] Template "${v.key}" auf Knoten "${r.id}" schaltet unbekannte Action "${A}" frei; deklariert: ${[...d.keys()].join(", ")||"keine"}.`,en:`[capability/danglingUnlock] Template "${v.key}" on node "${r.id}" unlocks the unknown action "${A}"; declared: ${[...d.keys()].join(", ")||"none"}.`},severity:"error"})}let m=new Set(a.map(v=>v.key));for(let v of Object.keys(r.assign??{}))m.has(v)||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.assign.${v}`,reason:{de:`[capability/unknownAssignKey] assign-Key "${v}" auf Knoten "${r.id}" ist kein intrinsisches Template dieses Knotentyps; bekannt: ${[...m].join(", ")||"keine"}.`,en:`[capability/unknownAssignKey] assign key "${v}" on node "${r.id}" is not an intrinsic template of this node type; known: ${[...m].join(", ")||"none"}.`},severity:"error"});let y=l.filter(v=>v.teamAssignable===!0).map(v=>v.id);for(let v of Object.keys(r.actionTeams??{}))y.includes(v)||n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actionTeams.${v}`,reason:{de:`[capability/unknownActionTeam] Knoten "${r.id}" nennt ein Team f\xFCr "${v}", aber diese Aktion l\xE4sst sich hier keinem Team geben; m\xF6glich: ${y.join(", ")||"keine"}.`,en:`[capability/unknownActionTeam] Node "${r.id}" names a team for "${v}", but this action cannot be given to a team here; possible: ${y.join(", ")||"none"}.`},severity:"error"});let k=new Set;for(let v of a)if(v.recipient==="external"||typeof(r.assign??{})[v.key]=="string")for(let A of v.unlocks)k.add(A);let g=i.strictActionCoverage===!0;for(let v of l){if(k.has(v.id)||v.superUserOnly===!0)continue;let E=a.find(I=>I.unlocks.includes(v.id)),A=E!==void 0?{de:` Fehlt die Zuweisung assign.${E.key}?`,en:` Is the assignment assign.${E.key} missing?`}:{de:"",en:""};n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.actions.${v.id}`,reason:{de:`[capability/superUserOnly] Action "${v.id}" auf Knoten "${r.id}" ist von keinem verdrahteten Work-Item freigeschaltet \u2014 nur die verantwortliche Person (Super-User) kann sie ausf\xFChren.${A.de}`,en:`[capability/superUserOnly] Action "${v.id}" on node "${r.id}" is unlocked by no wired work item \u2014 only the responsible person (super user) can perform it.${A.en}`},severity:g?"error":"warning"})}}return n}s(mH,"checkNodeCapabilityWiring");function hH(e){let n=new Set(QI()),t=[];for(let r of e.nodes)n.has(r.type)||t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.type`,reason:{de:`[graph/unknownNodeType] Knoten "${r.id}" hat den unbekannten Typ "${String(r.type)}". Registrierte Typen: ${[...n].join(", ")}.`,en:`[graph/unknownNodeType] Node "${r.id}" has the unknown type "${String(r.type)}". Registered types: ${[...n].join(", ")}.`},severity:"error"});return t}s(hH,"checkKnownNodeTypes");function gH(e,n){let t=[],r=s((a,l)=>{t.push({layer:"GRAPH",kind:"nodeRule",path:a,reason:l,severity:"error"})},"push"),i=tI(e),o=s(a=>typeof a=="object"&&a!==null&&Object.values(a).some(l=>typeof l=="string"&&l.trim().length>0),"hasText");for(let a of e.nodes){let l=a,d=Array.isArray(l.optionalActions)?l.optionalActions:[];if(t.push(...OH(l,d)),d.length===0)continue;let c=He(a),u=new Set(c.optionalActionKinds??[]),p=Array.isArray(l.tasks)?l.tasks:[],m=new Map;for(let g of p)typeof g.key=="string"&&m.set(g.key,g);let y=new Set,k=new Map;for(let g of d){let v=g.key,E=typeof v=="string"&&v.trim().length>0?v:void 0,A=E??"?",I=`nodes.${l.id}.optionalActions.${A}`,_=typeof g.action=="string"?g.action:void 0;if(g.when!==void 0){let T=s(b=>r(`${I}.when`,{de:`[optionalAction/when] Optionale Aktion "${A}" auf Knoten "${l.id}": ${b.de}`,en:`[optionalAction/when] Optional action "${A}" on node "${l.id}": ${b.en}`}),"conditionFinding");if(typeof g.when!="string"||g.when.trim()==="")T({de:"Die Bedingung ist leer \u2014 ohne Bedingung das Feld weglassen.",en:"The condition is empty \u2014 without a condition, omit the field."});else for(let b of tp(g.when,i,n))T(b)}if((_===void 0||!u.has(_))&&r(`${I}.action`,{de:`[optionalAction/kindNotDeclared] Optionale Aktion "${A}" auf Knoten "${l.id}" hat die Art ${JSON.stringify(g.action)} \u2014 `+(u.size===0?`Knotentyp "${l.type}" deklariert keine Familien (spec.optionalActionKinds fehlt).`:`Knotentyp "${l.type}" deklariert nur: ${[...u].join(", ")}.`),en:`[optionalAction/kindNotDeclared] Optional action "${A}" on node "${l.id}" has the kind ${JSON.stringify(g.action)} \u2014 `+(u.size===0?`node type "${l.type}" declares no families (spec.optionalActionKinds is missing).`:`node type "${l.type}" only declares: ${[...u].join(", ")}.`)}),E===void 0?r(`${I}.key`,{de:`[optionalAction/missingKey] Optionale Aktion auf Knoten "${l.id}" ohne (oder mit leerem) 'key' \u2014 Trigger-Action und Template-Keys w\xE4ren namenlos ('optionalAction::\u2026').`,en:`[optionalAction/missingKey] Optional action on node "${l.id}" without (or with an empty) 'key' \u2014 the trigger action and template keys would be nameless ('optionalAction::\u2026').`}):(y.has(E)&&r(`${I}.key`,{de:`[optionalAction/duplicateKey] Doppelter Aktions-Key "${E}" auf Knoten "${l.id}" \u2014 die projizierten Trigger-Actions w\xFCrden kollidieren.`,en:`[optionalAction/duplicateKey] Duplicate action key "${E}" on node "${l.id}" \u2014 the projected trigger actions would collide.`}),y.add(E)),o(g.label)||r(`${I}.label`,{de:`[optionalAction/missingLabel] Optionale Aktion "${A}" auf Knoten "${l.id}" ohne Label \u2014 der Trigger-Button w\xE4re unbeschriftet.`,en:`[optionalAction/missingLabel] Optional action "${A}" on node "${l.id}" without a label \u2014 the trigger button would be unlabeled.`}),_==="spawnTasks"){g.except!==void 0&&r(`${I}.except`,{de:`[optionalAction/exceptRetired] Optionale Aktion "${A}" auf Knoten "${l.id}" tr\xE4gt 'except' \u2014 das gibt es nicht mehr: solange die Aufgaben offen sind, ist die ganze Aktionsgruppe des Knotens gesperrt. 'except' entfernen.`,en:`[optionalAction/exceptRetired] Optional action "${A}" on node "${l.id}" carries 'except' \u2014 that no longer exists: while the tasks are open, the node's whole action group is locked. Remove 'except'.`});let T=Array.isArray(g.tasks)?g.tasks:void 0;if(T===void 0||T.length===0)r(`${I}.tasks`,{de:`[optionalAction/tasksEmpty] Optionale Aktion "${A}" auf Knoten "${l.id}" referenziert keine Aufgaben-Templates \u2014 der Trigger w\xFCrde nichts erzeugen.`,en:`[optionalAction/tasksEmpty] Optional action "${A}" on node "${l.id}" references no task templates \u2014 the trigger would create nothing.`});else{let b=new Set,R=new Set(T.filter(q=>typeof q=="string"));for(let q of T){let P=typeof q=="string"?q:void 0;if(P===void 0||P.length===0){r(`${I}.tasks`,{de:`[optionalAction/unknownTaskRef] Optionale Aktion "${A}" auf Knoten "${l.id}" enth\xE4lt eine leere/ung\xFCltige Template-Referenz.`,en:`[optionalAction/unknownTaskRef] Optional action "${A}" on node "${l.id}" contains an empty or invalid template reference.`});continue}if(b.has(P)){r(`${I}.tasks.${P}`,{de:`[optionalAction/duplicateTaskRef] Template "${P}" ist in der Aktion "${A}" auf Knoten "${l.id}" doppelt referenziert.`,en:`[optionalAction/duplicateTaskRef] Template "${P}" is referenced twice in the action "${A}" on node "${l.id}".`});continue}b.add(P);let J=m.get(P);if(J===void 0){r(`${I}.tasks.${P}`,{de:`[optionalAction/unknownTaskRef] Optionale Aktion "${A}" auf Knoten "${l.id}" referenziert das Template "${P}", das node.tasks nicht deklariert. Vorhanden: ${[...m.keys()].join(", ")||"keine"}.`,en:`[optionalAction/unknownTaskRef] Optional action "${A}" on node "${l.id}" references the template "${P}", which node.tasks does not declare. Present: ${[...m.keys()].join(", ")||"none"}.`});continue}let Y=k.get(P);Y!==void 0&&Y!==A?r(`${I}.tasks.${P}`,{de:`[optionalAction/taskDoublyBound] Template "${P}" auf Knoten "${l.id}" ist bereits von der Aktion "${Y}" referenziert \u2014 ein Template geh\xF6rt zu h\xF6chstens einer optionalen Aktion.`,en:`[optionalAction/taskDoublyBound] Template "${P}" on node "${l.id}" is already referenced by the action "${Y}" \u2014 a template belongs to at most one optional action.`}):k.set(P,A);let fe=J.blocks?.templateKey;typeof fe=="string"&&!R.has(fe)&&r(`${I}.tasks.${P}`,{de:`[optionalAction/taskRefBlocks] Template "${P}" auf Knoten "${l.id}" tr\xE4gt 'blocks' auf "${fe}", das nicht zur selben Aktion "${A}" geh\xF6rt \u2014 eine Referenz darf nur eine Referenz DERSELBEN Aktion zur\xFCckhalten (Checklisten-Reihenfolge), nie ein Template au\xDFerhalb.`,en:`[optionalAction/taskRefBlocks] Template "${P}" on node "${l.id}" carries 'blocks' on "${fe}", which does not belong to the same action "${A}" \u2014 a reference may only hold back a reference of the SAME action (checklist order), never a template outside it.`});for(let Q of p){let re=typeof Q.key=="string"?Q.key:void 0;Q.blocks?.templateKey===P&&(re!==void 0&&R.has(re)||r(`${I}.tasks.${P}`,{de:`[optionalAction/taskRefBlocks] Template "${P}" auf Knoten "${l.id}" ist Ziel eines 'blocks' von ${re!==void 0?`"${re}"`:"einem Template"} au\xDFerhalb der Aktion "${A}" \u2014 ein Template au\xDFerhalb darf eine Referenz nie zur\xFCckhalten (ihr Spawn geh\xF6rt dem Trigger, nicht onEnter).`,en:`[optionalAction/taskRefBlocks] Template "${P}" on node "${l.id}" is the target of a 'blocks' from ${re!==void 0?`"${re}"`:"a template"} outside the action "${A}" \u2014 a template outside may never hold back a reference (its spawn belongs to the trigger, not to onEnter).`}))}}}}}}return t}s(gH,"checkOptionalActions");function yH(e){return typeof e=="number"?"number":typeof e=="boolean"?"boolean":"string"}s(yH,"literalValueType");function wH(e,n){let t=[],r=n?.notificationTemplates;for(let i of e.nodes){let o=i,a=RP(i,He(i)),l=o.notifications??{};if(a.length===0&&Object.keys(l).length===0)continue;let d=new Map(a.map(c=>[c.id,c]));for(let c of Object.keys(l))d.has(c)||t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${o.id}.notifications.${c}`,reason:{de:`[notification/unknownEvent] Knoten "${o.id}" bindet einen Brief an das Ereignis "${c}", das der Knotentyp "${o.type}" nicht kennt. Angeboten werden: ${a.map(u=>u.id).join(", ")||"(keine)"}.`,en:`[notification/unknownEvent] Node "${o.id}" binds a letter to the event "${c}", which the node type "${o.type}" does not know. Offered: ${a.map(u=>u.id).join(", ")||"(none)"}.`},severity:"error"});for(let c of a){let u=l[c.id];if(c.required===!0&&(u===void 0||u.disabled===!0)){t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${o.id}.notifications.${c.id}`,reason:{de:`[notification/missingBinding] Knoten "${o.id}" muss beim Ereignis "${c.label.de}" (${c.id}) einen Brief verschicken \u2014 es ist ${u===void 0?"keiner gebunden":"einer gebunden, aber abgeschaltet"}.`,en:`[notification/missingBinding] Node "${o.id}" must send a letter on the event "${c.label.en}" (${c.id}) \u2014 ${u===void 0?"none is bound":"one is bound, but switched off"}.`},severity:"error"});continue}if(u===void 0||u.disabled===!0)continue;let p=`nodes.${o.id}.notifications.${c.id}`;if(c.audience!=="external"){t.push({layer:"GRAPH",kind:"nodeRule",path:p,reason:{de:`[notification/internalAudienceUnsupported] Knoten "${o.id}": das Ereignis "${c.id}" richtet sich an die Schule, und Briefe an die Schule k\xF6nnen noch nicht zugestellt werden \u2014 der gebundene Brief "${u.templateId}" w\xFCrde den Vorgang beim Versand abbrechen.`,en:`[notification/internalAudienceUnsupported] Node "${o.id}": the event "${c.id}" is addressed to the school, and letters to the school cannot be delivered yet \u2014 the bound letter "${u.templateId}" would abort the process when it is sent.`},severity:"error"});continue}if(r===void 0)continue;let m=r.get(u.templateId);if(m===void 0){t.push({layer:"GRAPH",kind:"nodeRule",path:p,reason:{de:`[notification/unknownTemplate] Knoten "${o.id}": der Brief "${u.templateId}" ist nicht im Katalog. Bekannt sind: ${[...r.keys()].sort().join(", ")||"(keine)"}.`,en:`[notification/unknownTemplate] Node "${o.id}": the letter "${u.templateId}" is not in the catalog. Known: ${[...r.keys()].sort().join(", ")||"(none)"}.`},severity:"error"});continue}m.audience!==void 0&&m.audience!==c.audience&&t.push({layer:"GRAPH",kind:"nodeRule",path:p,reason:{de:`[notification/audienceMismatch] Der Brief "${m.id}" ist f\xFCr ${m.audience==="internal"?"die Schule":"die Familie"} geschrieben, das Ereignis "${c.id}" richtet sich aber an die Familie.`,en:`[notification/audienceMismatch] The letter "${m.id}" is written for ${m.audience==="internal"?"the school":"the family"}, but the event "${c.id}" is addressed to the family.`},severity:"warning"});let y=SP(c),k=new Set(m.params.map(g=>g.key));for(let g of Object.keys(u.args??{}))k.has(g)||t.push({layer:"GRAPH",kind:"nodeRule",path:`${p}.args.${g}`,reason:{de:`[notification/unknownArg] Der Brief "${m.id}" hat kein Argument "${g}" \u2014 erwartet werden: ${m.params.map(v=>v.key).join(", ")||"(keine)"}.`,en:`[notification/unknownArg] The letter "${m.id}" has no argument "${g}" \u2014 expected: ${m.params.map(v=>v.key).join(", ")||"(none)"}.`},severity:"error"});for(let g of m.params){let v=u.args?.[g.key],E=`${p}.args.${g.key}`;if(v!==void 0&&"literal"in v){let I=yH(v.literal);g.type!==void 0&&!lw(I,g.type)&&t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/argTypeMismatch] "${g.key}" erwartet ${Ol(g.type).de}, festgelegt ist aber ${JSON.stringify(v.literal)} (${I}).`,en:`[notification/argTypeMismatch] "${g.key}" expects ${Ol(g.type).en}, but ${JSON.stringify(v.literal)} (${I}) is set.`},severity:"error"});continue}if(v!==void 0){t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/unsupportedArg] "${g.key}" ist an ${JSON.stringify(v)} gebunden \u2014 ein Brief-Argument kann nur ein Festwert ({ literal }) sein oder automatisch aus ${x_(y,"de")} kommen.`,en:`[notification/unsupportedArg] "${g.key}" is bound to ${JSON.stringify(v)} \u2014 a letter argument can only be a fixed value ({ literal }) or come automatically from ${x_(y,"en")}.`},severity:"error"});continue}let A=AP(g,y.get(g.key)??[]);if(!(A.status==="resolved"||A.status==="unused")){if(A.status==="sometimes"){t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/unresolvedArg] Der Brief "${m.id}" braucht "${g.key}" immer, ${A.source.source} liefert es aber nur manchmal. In notifications.${c.id}.args.${g.key} einen Festwert benennen \u2014 oder einen Brief w\xE4hlen, der ohne "${g.key}" auskommt.`,en:`[notification/unresolvedArg] The letter "${m.id}" always needs "${g.key}", but ${A.source.source} provides it only sometimes. Name a fixed value in notifications.${c.id}.args.${g.key} \u2014 or choose a letter that works without "${g.key}".`},severity:"error"});continue}if(A.status==="ambiguous"){t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/ambiguousArg] "${g.key}" hat mehrere passende Quellen \u2014 ${A.matches.map(I=>I.source).join(", ")}. In notifications.${c.id}.args.${g.key} einen Festwert setzen.`,en:`[notification/ambiguousArg] "${g.key}" has several matching sources \u2014 ${A.matches.map(I=>I.source).join(", ")}. Set a fixed value in notifications.${c.id}.args.${g.key}.`},severity:"error"});continue}t.push({layer:"GRAPH",kind:"nodeRule",path:E,reason:{de:`[notification/unresolvedArg] Der Brief "${m.id}" braucht "${g.key}"${g.type!==void 0?` (${Ol(g.type).de})`:""}, und der Knoten hat daf\xFCr ${A.rejected.length===0?"keine Quelle":`nur unpassende Quellen: ${A.rejected.map(I=>`${I.source} (${I.type})`).join(", ")}`}.`,en:`[notification/unresolvedArg] The letter "${m.id}" needs "${g.key}"${g.type!==void 0?` (${Ol(g.type).en})`:""}, and the node has ${A.rejected.length===0?"no source for it":`only unsuitable sources for it: ${A.rejected.map(I=>`${I.source} (${I.type})`).join(", ")}`}.`},severity:"error"})}}}}return t}s(wH,"checkNotificationBindings");function kH(e){return oN(e).map(n=>({layer:"GRAPH",kind:"assignment",path:"assignmentRules",reason:n,severity:"error"}))}s(kH,"checkAssignmentRules");function x_(e,n){let t=[...e.keys()].sort();return t.length===0?n==="de"?"(nichts)":"(nothing)":t.join(", ")}s(x_,"describeCandidates");function bH(e,n){return lN(e,n?.teamKeys).map(t=>({layer:"GRAPH",kind:"nodeRule",path:t.path,reason:t.reason,severity:"error"}))}s(bH,"checkChannels");function vH(e){return iI(e).map(n=>({layer:"GRAPH",kind:"nodeRule",path:n.path,reason:n.reason,severity:"error"}))}s(vH,"checkStaffInputs");function xH(e,n){let t=[];for(let r of e.nodes){let i=r.reads;if(i===void 0)continue;let o=`nodes.${r.id}.reads`,a={de:`Knoten \u201E${Oe(e,r.id,"de")}\u201C (${r.id})`,en:`Node "${Oe(e,r.id,"en")}" (${r.id})`},l=s(c=>{t.push({layer:"GRAPH",kind:"nodeRule",path:o,reason:c,severity:"error"})},"issue");if(!wN(r)){l({de:`[readiness/readsNotGated] ${a.de} (${r.type}) deklariert \`reads\`, aber die Bereitschaftspr\xFCfung h\xE4lt nur Entscheidungs-Knoten und Dokument-Knoten mit Produktion \u2014 hier w\xFCrde \`reads\` nichts bewirken.`,en:`[readiness/readsNotGated] ${a.en} (${r.type}) declares \`reads\`, but the readiness check only holds decision nodes and document nodes with production \u2014 here \`reads\` would have no effect.`});continue}if(!Array.isArray(i)){l({de:`[readiness/readsDuplicate] \`reads\` von ${a.de} muss eine Liste von Feldadressen sein, erhalten ${JSON.stringify(i)}.`,en:`[readiness/readsDuplicate] \`reads\` of ${a.en} must be a list of field addresses, got ${JSON.stringify(i)}.`});continue}let d=new Set;for(let c of i){if(!we(c))continue;let u=se(c);if(d.has(u)){l({de:`[readiness/readsDuplicate] ${a.de} liest ${Ve(e,c,"de")} mehrfach.`,en:`[readiness/readsDuplicate] ${a.en} reads ${Ve(e,c,"en")} more than once.`});continue}if(d.add(u),!fn(c)){l({de:`[readiness/readsUnknownField] ${a.de} liest ${Ve(e,c,"de")} \u2014 \`reads\` nennt nur Felder eines Formulars ($node.<formular>.admission.<feld>).`,en:`[readiness/readsUnknownField] ${a.en} reads ${Ve(e,c,"en")} \u2014 \`reads\` only names fields of a form ($node.<form>.admission.<field>).`});continue}let p=oi(n,c);p!=null&&Fs("nodeReads",Ds(p))==="repeated"&&l({de:`[readiness/readsUnknownField] ${a.de} liest ${Ve(e,c,"de")} \u2014 ein Feld in einer Wiederholgruppe ist kein einzelnes Feld der Anmeldung und kann nicht gelesen werden.`,en:`[readiness/readsUnknownField] ${a.en} reads ${Ve(e,c,"en")} \u2014 a field in a repeated group is not a single field of the application and cannot be read.`})}}return t}s(xH,"checkReadinessReads");function SH(e,n){let t=[];for(let r of e.nodes){if(r.type!=="setFlag")continue;let i=dO(r),o=xf(r);if(i===null||o===null)continue;let a=n?.formFlagKeysByFormNode?.get(i);if(a===void 0||a.has(o))continue;let l=[...a].sort();t.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${r.id}.inputs.${On.flagKey}`,reason:{de:`[setFlag/unknownFlag] Knoten \u201E${Oe(e,r.id,"de")}\u201C (${r.id}) setzt \u201E${o}\u201C, aber das Formular von \u201E${Oe(e,i,"de")}\u201C hat kein externes Merkmal dieses Namens`+(l.length>0?` (vorhanden: ${l.join(", ")}).`:" \u2014 es deklariert gar keins."),en:`[setFlag/unknownFlag] Node "${Oe(e,r.id,"en")}" (${r.id}) sets "${o}", but the form of "${Oe(e,i,"en")}" has no external flag of that name`+(l.length>0?` (present: ${l.join(", ")}).`:" \u2014 it declares none at all.")},severity:"error"})}return t}s(SH,"checkSetFlagKeys");function AH(e,n){let t=n?.readinessFormFieldsByFormNode,r=n?.readinessPartyConditionKeysByFormNode;if(t===void 0||r===void 0)return[];let i=[];for(let o of e.nodes){if(o.type!=="governedDocument"||o.production!=="resolver")continue;let a=o.form;if(!we(a)||!wr(a))continue;let l=t.get(a.owner),d=r.get(a.owner);if(l===void 0||d===void 0||d.size===0)continue;let c=vw(l,d);if(c.size===0)continue;let u=o.reads,p=(Array.isArray(u)?u:[]).filter(g=>fn(g)&&g.owner===a.owner),m=vw(l,[...p.map(g=>g.path),...vN(o).filter(g=>g.owner===a.owner).map(g=>g.fieldKey)]),y=[...c].filter(g=>!m.has(g)).sort();if(y.length===0)continue;let k={de:Oe(e,a.owner,"de"),en:Oe(e,a.owner,"en")};i.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${o.id}.reads`,reason:{de:`[readiness/readsMissesPartyCondition] Knoten \u201E${Oe(e,o.id,"de")}\u201C (${o.id}) erzeugt ein Dokument, dessen Vertragsparteien von Angaben im Formular \u201E${k.de}\u201C abh\xE4ngen, die er weder liest noch bindet: ${y.join(", ")}. Eine Korrektur darauf h\xE4lt den Knoten nicht an und kann nach der Ausstellung eine Vertragspartei entfernen \u2014 die Felder (oder den berechneten Schl\xFCssel) aus \u201E${k.de}\u201C in \`reads\` erg\xE4nzen.`,en:`[readiness/readsMissesPartyCondition] Node "${Oe(e,o.id,"en")}" (${o.id}) generates a document whose contract parties depend on answers in the form "${k.en}" that it neither reads nor binds: ${y.join(", ")}. A correction to them does not hold the node and can remove a contract party after issuing \u2014 add the fields (or the computed key) from "${k.en}" to \`reads\`.`},severity:"warning"})}return i}s(AH,"checkReadinessPartyConditions");function Dw(e){let n=Object.keys(e.inputs??{});if(n.length===0)return[];let t=e.generatorStamp,r=e.production,i=e.templateStamp;if(e.type==="governedDocument"&&(r==="resolver"&&!Array.isArray(t?.inputSchema?.fields)||r==="template"&&!Array.isArray(i?.fields)))return[];let a=new Set(Ks(e).map(l=>l.id));return n.filter(l=>!a.has(l))}s(Dw,"undeclaredInputKeys");function EH(e,n){return e.nodes.flatMap(t=>[...$H(e,t,Ks(t),n),...TH(e,t,n)])}s(EH,"checkUnknownResources");function TH(e,n,t){let r=[],i=new Set((He(n).workItemTemplates?.(n)??[]).map(o=>o.key));for(let o of Of(n)){if(o.leaf==="assign{}"&&!i.has(o.owner))continue;let a=_s[o.leaf],l=`nodes.${n.id}.${o.path}`,d=s(p=>p==="de"?`Knoten \u201E${Oe(e,n.id,"de")}\u201C (${n.id}), ${a.what.de} \u201E${o.owner}\u201C`:`node "${Oe(e,n.id,"en")}" (${n.id}), ${a.what.en} "${o.owner}"`,"where");if(o.missing){if(!a.required){r.push({layer:"GRAPH",kind:"nodeRule",path:l,severity:"error",reason:{de:`[inputs/emptyReference] ${d("de")}: der Eintrag ist leer oder kein Schl\xFCssel \u2014 ${a.consequence.de}. Team w\xE4hlen oder den Eintrag entfernen.`,en:`[inputs/emptyReference] ${d("en")}: the entry is empty or no key \u2014 ${a.consequence.en}. Choose a team or remove the entry.`}});continue}r.push({layer:"GRAPH",kind:"nodeRule",path:l,severity:"error",reason:{de:`[workItems/needsTeam] ${d("de")}: kein Team gew\xE4hlt \u2014 ${a.consequence.de}. Jede Aufgabe geh\xF6rt der Warteschlange eines Teams.`,en:`[workItems/needsTeam] ${d("en")}: no team chosen \u2014 ${a.consequence.en}. Every task belongs to a team's queue.`}});continue}if(o.key===null)continue;let c=t?.teamKeys;if(c===void 0||c.has(o.key))continue;let u=[...c].sort().join(", ")||"\u2014";r.push({layer:"GRAPH",kind:"nodeRule",path:l,severity:"error",reason:{de:`[inputs/unknownResource] ${d("de")}: \u201E${o.key}\u201C ist kein Team dieses Mandanten \u2014 ${a.consequence.de}. Teams: ${u}.`,en:`[inputs/unknownResource] ${d("en")}: "${o.key}" is no team of this school \u2014 ${a.consequence.en}. Teams: ${u}.`}})}return r}s(TH,"referenceIssues");function $H(e,n,t,r){let i=[];for(let o of t){if(!Sf(o.type))continue;let a=Is[o.type].existence;if(a.check!=="generic")continue;let l=r?.[a.catalog];if(l===void 0)continue;let d=n.inputs?.[o.id];if(d?.kind!=="literal"||typeof d.value!="string"||l.has(d.value))continue;let c=Is[o.type].label;i.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${n.id}.inputs.${o.id}`,reason:{de:`[inputs/unknownResource] Knoten \u201E${Oe(e,n.id,"de")}\u201C (${n.id}) nennt im Eingang \u201E${o.label.de}\u201C ${c.de} \u201E${d.value}\u201C \u2014 diesen Schl\xFCssel kennt dieser Mandant nicht.`,en:`[inputs/unknownResource] Node "${Oe(e,n.id,"en")}" (${n.id}) names the ${c.en.toLowerCase()} "${d.value}" in its input "${o.label.en}", which does not exist in this school.`},severity:"error"})}return i}s($H,"unknownResourceIssues");function RH(e){let n=[];for(let t of e.nodes)for(let r of Dw(t))n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${t.id}.inputs.${r}`,reason:{de:`[inputs/undeclared] Knoten \u201E${Oe(e,t.id,"de")}\u201C (${t.id}) hat einen Eingang \u201E${r}\u201C, den sein Typ nicht deklariert \u2014 ein Rest einer fr\xFCheren Einstellung (z. B. eines anderen Generators). Im Parameter-Bereich ist er nicht sichtbar; entfernen.`,en:`[inputs/undeclared] Node "${Oe(e,t.id,"en")}" (${t.id}) has an input "${r}" its type does not declare \u2014 a leftover of an earlier setting (e.g. another generator). It is not visible among the parameters; remove it.`},severity:"error"});return n}s(RH,"checkUndeclaredInputs");function IH(e){let n=[];for(let t of e.nodes){let r=new Set;for(let i of Ks(t)){if(!r.has(i.id)){r.add(i.id);continue}n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${t.id}.inputs.${i.id}`,reason:{de:`[inputs/duplicateSlot] Knoten \u201E${Oe(e,t.id,"de")}\u201C (${t.id}) hat den Eingang \u201E${i.id}\u201C zweimal \u2014 ein Parameter des Generators oder der Vorlage tr\xE4gt den Namen eines Eingangs des Knotentyps. Den Parameter umbenennen.`,en:`[inputs/duplicateSlot] Node "${Oe(e,t.id,"en")}" (${t.id}) has the input "${i.id}" twice \u2014 a parameter of the generator or template carries the name of an input of the node type. Rename the parameter.`},severity:"error"})}}return n}s(IH,"checkDuplicateSlots");function A_(e,n,t){let r=[],i=hH(e);if(i.length>0)return i;r.push(...eH(e)),r.push(...ZY(e)),r.push(...nH(e)),r.push(...XY(e)),r.push(...HY(e)),r.push(...JY(e)),r.push(...QY(e)),r.push(...rH(e)),r.push(...QO(e,n)),r.push(...iH(e,n)),r.push(...oH(e,n)),r.push(...sH(e,n)),r.push(...EN(e,n?.layout)),r.push(...aH(e,n)),r.push(...lH(e,n)),r.push(...cH(e,n)),r.push(...BO(e,t)),r.push(...nP(e)),r.push(...oP(e,t)),r.push(...XO(e)),r.push(...eP(e)),r.push(...RH(e)),r.push(...EH(e,t)),r.push(...IH(e)),r.push(...uH(e)),r.push(...fH(e)),r.push(...VN(e,t)),r.push(...YN(e)),r.push(...zN(e)),r.push(...HN(e,t)),r.push(...XN(e,t)),r.push(...mH(e)),r.push(...wH(e,t)),r.push(...gH(e,t)),r.push(...kH(e)),r.push(...xH(e,t)),r.push(...AH(e,t)),r.push(...SH(e,t)),r.push(...bH(e,t)),r.push(...vH(e)),r.push(...v_(e));for(let o of e.nodes){let a=He(o);a.validate&&r.push(...a.validate(o,e,t))}return r}s(A_,"checkGraph");function OH(e,n){let t=e.requiresOneOf;if(t===void 0)return[];let r=`nodes.${e.id}.requiresOneOf`,i=s(d=>({layer:"GRAPH",kind:"nodeRule",path:r,reason:d,severity:"error"}),"issue");if(e.type!=="decision")return[i({de:`[decision/requiresOneOfNotDecision] Knoten "${e.id}" (Typ "${e.type}") tr\xE4gt 'requiresOneOf' \u2014 die Regel gilt nur an Entscheidungsknoten (decision).`,en:`[decision/requiresOneOfNotDecision] Node "${e.id}" (type "${e.type}") carries 'requiresOneOf' \u2014 the rule only applies to decision nodes (decision).`})];if(!Array.isArray(t)||t.length===0||t.some(d=>typeof d!="string"||d.length===0))return[i({de:`[decision/requiresOneOfEmpty] 'requiresOneOf' an Knoten "${e.id}" muss eine nicht-leere Liste von Aktions-Keys sein \u2014 sonst Feld weglassen.`,en:`[decision/requiresOneOfEmpty] 'requiresOneOf' on node "${e.id}" must be a non-empty list of action keys \u2014 otherwise omit the field.`})];let o=n.map(d=>d.key).filter(d=>typeof d=="string"),a=[],l=new Set;for(let d of t){if(l.has(d)){a.push(i({de:`[decision/requiresOneOfDuplicate] 'requiresOneOf' an Knoten "${e.id}" nennt "${d}" doppelt.`,en:`[decision/requiresOneOfDuplicate] 'requiresOneOf' on node "${e.id}" names "${d}" twice.`}));continue}l.add(d),o.includes(d)||a.push(i({de:`[decision/requiresOneOfUnknownAction] 'requiresOneOf' an Knoten "${e.id}" nennt "${d}", aber dieser Knoten hat keine optionale Aktion mit diesem Key \u2014 die Regel w\xE4re nie erf\xFCllbar. `+(o.length===0?"Der Knoten hat keine optionalen Aktionen.":`Optionale Aktionen dieses Knotens: ${o.join(", ")}.`),en:`[decision/requiresOneOfUnknownAction] 'requiresOneOf' on node "${e.id}" names "${d}", but this node has no optional action with that key \u2014 the rule could never be met. `+(o.length===0?"The node has no optional actions.":`Optional actions of this node: ${o.join(", ")}.`)}))}return a}s(OH,"checkRequiresOneOf");function PH(e){return e.nodes.flatMap(n=>Dw(n).map(t=>({nodeId:n.id,key:t,binding:n.inputs?.[t]?.kind==="binding"})))}s(PH,"undeclaredInputCells");function E_(e,n){let t=PH(e).filter(o=>n.bindings||!o.binding);if(t.length===0)return{graph:e,dropped:t};let r=new Map;for(let o of t)r.set(o.nodeId,(r.get(o.nodeId)??new Set).add(o.key));let i=e.nodes.map(o=>{let a=r.get(String(o.id));if(a===void 0)return o;let l=Object.fromEntries(Object.entries(o.inputs).filter(([d])=>!a.has(d)));return{...o,inputs:l}});return{graph:{...e,nodes:i},dropped:t}}s(E_,"dropUndeclaredInputs");function Fw(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Fw,"isObject");function T_(e){return Fw(e)&&e.type==="governedDocument"&&("template"in e||"cockpitFields"in e)}s(T_,"oldShape");function $_(e){return(e?.nodes??[]).some(T_)}s($_,"needsTemplateStampMove");function NH(e){let n=e.generatorStamp?.inputSchema?.fields;if(e.production==="resolver")return Array.isArray(n)?n:null;let t=e.templateStamp?.fields;return e.production==="template"&&Array.isArray(t)?t:null}s(NH,"stampedFields");function _H(e){let n=String(e.id);if("template"in e&&"templateStamp"in e)return{unmoved:{nodeId:n,reason:"templateAndStamp"}};let t={...e},r=[];if("template"in e){let{template:i}=e;if(delete t.template,Fw(i))t.templateStamp={fields:Array.isArray(i.fields)?i.fields:[],...i.localeField===void 0?{}:{localeField:i.localeField}};else return{unmoved:{nodeId:n,reason:"templateNotObject"}}}if("cockpitFields"in e){let i=Array.isArray(e.cockpitFields)?e.cockpitFields.filter(l=>typeof l=="string"):[];delete t.cockpitFields;let o=Fw(e.inputs)?{...e.inputs}:{},a=NH(t);if(a===null&&i.length>0)return{unmoved:{nodeId:n,key:i[0],reason:"noStamp"}};for(let l of i){let d=l in o&&o[l]?.kind!=="unset",c=(a??[]).find(u=>u.key===l);if(c===void 0)r.push({nodeId:n,key:l,reason:"unknownKey"});else{if(c.type==="party"||c.type==="personList")continue;c.processSource!==void 0?r.push({nodeId:n,key:l,reason:"processSource"}):d?r.push({nodeId:n,key:l,reason:"cellExists"}):o[l]={kind:"cockpit"}}}t.inputs=o}return{node:t,reports:r}}s(_H,"moveNode");function R_(e){let n=[],t=[],r=[],i=e.nodes.map(o=>{if(!T_(o))return o;let a=_H(o);return"unmoved"in a?(r.push(a.unmoved),o):(n.push(String(o.id)),t.push(...a.reports),a.node)});return n.length===0?{graph:e,moved:n,reports:t,unmoved:r}:{graph:{...e,nodes:i},moved:n,reports:t,unmoved:r}}s(R_,"moveTemplateStampAndCockpit");var I_=ef,CH="applicant.applicationSubmitted";function bp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(bp,"isObject");function O_(e){return bp(e)&&e.type==="form"&&typeof e.id=="string"&&!vt(e)}s(O_,"isCreatingFormNode");function DH(e){return bp(e.notifications)&&I_ in e.notifications}s(DH,"hasSubmittedBinding");function Lw(e){let n={toBind:[],alreadyBound:[],malformed:[]};for(let t of e?.nodes??[])O_(t)&&(t.notifications!==void 0&&!bp(t.notifications)?n.malformed.push(t.id):DH(t)?n.alreadyBound.push(t.id):n.toBind.push(t.id));return n}s(Lw,"submitReceiptInventory");function P_(e){let{toBind:n}=Lw(e);if(n.length===0)return{graph:e,bound:[]};let t=new Set(n),r=e.nodes.map(i=>{if(!O_(i)||!t.has(i.id))return i;let o=bp(i.notifications)?i.notifications:{};return{...i,notifications:{...o,[I_]:{templateId:CH}}}});return{graph:{...e,nodes:r},bound:n}}s(P_,"bindSubmitReceipt");var No=["park","advance"],Xt="whenNothingOwed",N_={park:{de:"Jemand schaut drauf",en:"Someone looks at it"},advance:{de:"Durchreichen",en:"Pass through"}};function __(e){let n=e.inputs?.[Xt],t=n?.kind==="literal"?n.value:void 0;return Mw(t)?t:null}s(__,"reviewModeOrNull");function Mw(e){return No.includes(e)}s(Mw,"isReviewMode");function qw(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(qw,"isObject");function C_(e){return qw(e)&&e.type==="review"&&!(qw(e.inputs)&&Xt in e.inputs)}s(C_,"lacksMode");function D_(e){return(e?.nodes??[]).some(C_)}s(D_,"needsReviewMode");function F_(e){let n=[],t=e.nodes.map(r=>{if(!C_(r))return r;n.push(r.id);let i=qw(r.inputs)?r.inputs:{};return{...r,inputs:{...i,[Xt]:{kind:"literal",value:"park"}}}});return{graph:{...e,nodes:t},set:n}}s(F_,"setReviewModePark");function vp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(vp,"isObject");function L_(e){let{notifications:n,bound:t}=Gf(e.notifications,{tasks:[]},e);return{next:n,bound:t}}s(L_,"bindingsFor");function M_(e){let n={toBind:[],malformed:[]};for(let t of e?.nodes??[])if(!(!vp(t)||typeof t.id!="string"||Gs(t).length===0)){if(t.notifications!==void 0&&!vp(t.notifications)){n.malformed.push(t.id);continue}for(let r of L_(t).bound)n.toBind.push(`${t.id}.${r}`)}return n}s(M_,"appointmentLetterInventory");function q_(e){let n=[],t=!1,r=e.nodes.map(i=>{if(!vp(i)||typeof i.id!="string"||Gs(i).length===0||i.notifications!==void 0&&!vp(i.notifications))return i;let{next:o,bound:a}=L_(i);return a.length===0?i:(t=!0,n.push(...a.map(l=>`${i.id}.${l}`)),{...i,notifications:o})});return t?{graph:{...e,nodes:r},bound:n}:{graph:e,bound:[]}}s(q_,"bindAppointmentLetters");function ra(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(ra,"isObject");var K_=["id","label","dataFlow"],j_=["audience","populates","stages","expectedOutcomes"];function B_(e){return Array.isArray(e.assignmentRules)&&e.assignmentRules.some(n=>ra(n)&&typeof n.slot=="string")}s(B_,"carriesStringSlots");function V_(e){return(e.nodes??[]).some(n=>ra(n)&&n.type==="form"&&j_.some(t=>t in n))}s(V_,"carriesRetiredFormNodeKey");var FH=[{key:"generatorPin",editor:!0,holds:II,what:{de:"Generator als `resolver`",en:"generator as `resolver`"}},{key:"setFlagProperties",editor:!0,holds:mO,what:{de:"Formular und Merkmal eines \u201EFlag setzen\u201C-Knotens als Eigenschaften",en:'form and flag of a "Set flag" node as properties'}},{key:"scalarProperties",editor:!0,holds:bO,what:{de:"Einstellungen eines Knotens als Eigenschaften statt als Eing\xE4nge",en:"a node's settings as properties instead of inputs"}},{key:"nodeConfigProperties",editor:!0,holds:RO,what:{de:"Hinweis einer Zahlung als Eigenschaft oder ein entferntes Muster-Dokument",en:"a payment's note as a property, or a removed sample document"}},{key:"outcomeWithoutSemantic",editor:!0,holds:kI,what:{de:"Entscheidungsausg\xE4nge ohne Bedeutung",en:"decision outcomes without a meaning"}},{key:"startNodeOutcomes",editor:!0,holds:SI,what:{de:"ein Start-Knoten mit eigenen Ausg\xE4ngen",en:"a start node with its own outcomes"}},{key:"templateParameters",editor:!0,holds:$_,what:{de:"Parameter einer Vorlage am Knoten oder Cockpit-Felder als Liste",en:"a template's parameters on the node, or cockpit fields as a list"}},{key:"reviewWithoutMode",editor:!0,holds:D_,what:{de:"Pr\xFCfknoten ohne \u201EWenn nichts zu pr\xFCfen ist\u201C",en:'review nodes without "When nothing is owed"'}},{key:"taskAssignUser",editor:!1,holds:s(e=>If(e).length>0,"holds"),what:{de:"eine Aufgabe mit fester Person (`assign.userId`)",en:"a task with a fixed person (`assign.userId`)"}},{key:"retiredGraphKey",editor:!1,holds:s(e=>K_.some(n=>n in e),"holds"),what:{de:"`graph.id` / `graph.label` / `graph.dataFlow`",en:"`graph.id` / `graph.label` / `graph.dataFlow`"}},{key:"assignmentSlotString",editor:!1,holds:B_,what:{de:"Zust\xE4ndigkeitsregeln mit Slot als Text (`responsible` / `team:<Schl\xFCssel>`)",en:"assignment rules with a slot as text (`responsible` / `team:<key>`)"}},{key:"retiredFormNodeKey",editor:!1,holds:V_,what:{de:"Formularknoten mit `audience` / `populates` / `stages` / `expectedOutcomes`",en:"form nodes with `audience` / `populates` / `stages` / `expectedOutcomes`"}}];function U_(e){if(!ra(e)||!Array.isArray(e.nodes))return[];let n=e;return FH.filter(t=>t.holds(n)).map(({key:t,what:r,editor:i})=>({key:t,what:r,editor:i}))}s(U_,"legacyGraphShapes");function G_(e,n){let t=n.answers??{},r=[],i=[],o=e,a=K_.filter(T=>T in o);if(a.length>0){let T={...o};for(let b of a)delete T[b],r.push({message:`graph.${b}: deleted (read by nothing)`});o=T}if(V_(o)&&(o={...o,nodes:o.nodes.map(T=>{if(!ra(T)||T.type!=="form")return T;let b=j_.filter(q=>q in T);if(b.length===0)return T;let R={...T};for(let q of b)delete R[q];return r.push({nodeId:String(T.id),message:`form node: deleted ${b.map(q=>`\`${q}\``).join(", ")} (read by nothing)`}),R})}),B_(o)){let T=o.assignmentRules.map((b,R)=>{if(!ra(b)||typeof b.slot!="string")return b;let q=pf(b.slot);return q===null?(i.push({code:"assignment/slotUnknown",answer:"edit",message:`assignmentRules[${R}].slot "${b.slot}" is neither \`responsible\` nor \`team:<key>\` \u2014 edit it by hand`}),b):(r.push({message:`assignmentRules[${R}].slot "${b.slot}" \u2192 ${JSON.stringify(q)}`}),{...b,slot:q})});o={...o,assignmentRules:T}}let l=OI(o);o=l.graph;for(let T of l.moved)r.push({nodeId:T,message:"generator / template pin moved into its input"});for(let T of l.unmoved)i.push({code:`generatorPin/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`the generator or template pin cannot be moved (${T.reason}) \u2014 edit the node by hand`});let d=hO(o);o=d.graph;for(let T of d.moved)r.push({nodeId:T,message:"setFlag `target` / `flagKey` / `value` moved into its inputs"});for(let T of d.unmoved)i.push({code:`setFlag/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`the setFlag properties cannot be moved (${T.reason}) \u2014 edit the node by hand`});let c=vO(o);o=c.graph;for(let T of c.moved)r.push({nodeId:T,message:"scalar settings moved into inputs"});for(let T of c.unmoved)i.push({code:`scalar/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`\`${T.key}\` cannot be moved into an input (${T.reason}) \u2014 edit the node by hand`});let u=IO(o);o=u.graph;for(let T of u.moved)r.push({nodeId:T,message:"payment note moved into `inputs.reason` / retired sample document deleted"});for(let T of u.unmoved)i.push({code:`nodeConfig/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`\`${T.key}\` cannot be moved into an input (${T.reason}) \u2014 edit the node by hand`});let p=R_(o);o=p.graph;for(let T of p.moved){let b=o.nodes.find(P=>ra(P)&&P.id===T),R=b?.inputs?.documentTemplate,q=R?.kind==="literal"&&typeof R.value=="string"?R.value:null;r.push({nodeId:T,message:b!==void 0&&"templateStamp"in b&&q!==null?`template parameters moved onto \`templateStamp\` / cockpit list into cells \u2014 the record \`${q}\` must declare the same parameters (tenant catalog \`documentTemplates[].parameters\` / \`templates:setParameters\`) before publish, else [governedDocument/templateWithoutParameters]`:"cockpit list moved into `{ kind: 'cockpit' }` cells"})}for(let T of p.reports)r.push({nodeId:T.nodeId,message:`cockpit field \`${T.key??""}\` deleted (${T.reason}: ${T.reason==="unknownKey"?"the stamp declares no such parameter":T.reason==="processSource"?"the case fills it itself":"the input already holds a cell"})`});for(let T of p.unmoved)i.push({code:`templateStamp/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:T.reason==="noStamp"?"the cockpit list cannot be judged: the node carries no parameter stamp \u2014 run `offer workflow restamp-pins` against the environment, then upgrade again":T.reason==="templateAndStamp"?"the node carries both `template` and `templateStamp` \u2014 delete one by hand":"`template` is no object \u2014 edit the node by hand"});let m=AI(o);o=m.graph;for(let T of m.moved)r.push({nodeId:T,message:"start node: own `outcomes` / `event` / `effect` deleted (the node type declares its outcome)"});for(let T of m.unmoved)i.push({code:`eventTrigger/${T.reason}`,nodeId:T.nodeId,answer:"edit",message:`the start node cannot be reduced to its type's outcome (${T.reason}) \u2014 edit the node by hand`});let y=bI(o,t.semantics);o=y.graph;for(let T of y.written){if(T.source==="formerDefault"){r.push({nodeId:T.nodeId,message:`outcome \`${T.outcomeId}\`: semantic "${T.semantic}" (DEFAULT \u2014 the meaning it ran with; the retired id parser knew no other)`,defaulted:{answer:"semantic",answerKey:`${T.nodeId}.${T.outcomeId}`,value:T.semantic}});continue}r.push({nodeId:T.nodeId,message:`outcome \`${T.outcomeId}\`: semantic "${T.semantic}" (${T.source==="answer"?"answered":"the meaning the retired id parser gave this id"})`})}for(let T of y.refused)i.push({code:T.answer===void 0?"outcome/formerMeaningNotAllowed":"outcome/semanticNotAllowed",nodeId:T.nodeId,answer:"semantic",answerKey:`${T.nodeId}.${T.outcomeId}`,candidates:T.allowed,message:T.answer===void 0?`${T.nodeType} outcome \`${T.outcomeId}\` ran as "${fy(T.outcomeId)??""}", which a ${T.nodeType} outcome may no longer carry \u2014 say which one it is`:`${T.nodeType} outcome \`${T.outcomeId}\`: "${T.answer}" is not a meaning a ${T.nodeType} outcome may carry`});for(let T of y.invalid)i.push({code:"outcome/semanticInvalid",nodeId:T.nodeId,answer:"edit",candidates:bt,message:`outcome \`${T.outcomeId}\` carries the semantic "${T.value}", which is no meaning \u2014 edit it`});let k=$I(o,n.selection,t.waitlistPolicy);o=k.graph;for(let T of k.moved){let b=T.policy.waitlistOrder;r.push({nodeId:T.nodeId,message:`waitlist policy into inputs: ${LH(T.policy)} (${T.source==="answer"?"answered":T.source==="manifest"?"from manifest `selection`":"DEFAULT \u2014 the manifest stated no `selection.waitlistOrder`; the former code default it ran with"})`,...T.source==="formerDefault"?{defaulted:{answer:"waitlistPolicy",answerKey:T.nodeId,value:b}}:{}})}for(let T of k.refused)i.push({code:`waitlist/${T.reason}`,nodeId:T.nodeId,answer:"waitlistPolicy",answerKey:T.nodeId,candidates:Yt,message:"manifest `selection` is malformed \u2014 say the queue order of this waitlist"});if(PO(o)){let T=NO(o,t.payee);o=T.graph;for(let b of T.set)r.push({nodeId:b.nodeId,message:`online payment: payee "${b.payee}" (answered)`});for(let b of T.refused)i.push({code:"collectPayment/payeeMissing",nodeId:b,answer:"payee",answerKey:b,message:"an online payment names the Tr\xE4ger its money goes to \u2014 say its key (a `legal_entities.configKey` of the tenant)"})}for(let T of Lw(o).malformed)i.push({code:"submitReceipt/notificationsMalformed",nodeId:T,answer:"edit",message:"the form node's `notifications` is no record \u2014 edit it by hand"});let g=P_(o);o=g.graph;for(let T of g.bound)r.push({nodeId:T,message:"submit receipt bound to `notifications.submitted` (`applicant.applicationSubmitted`, sent by code before)"});let v=F_(o);o=v.graph;for(let T of v.set)r.push({nodeId:T,message:"review: `whenNothingOwed` = park (every review parked before the input existed)"});for(let T of M_(o).malformed)i.push({code:"appointmentLetters/notificationsMalformed",nodeId:T,answer:"edit",message:"the node's `notifications` is no record \u2014 edit it by hand"});let E=q_(o);o=E.graph;for(let T of E.bound){let b=T.indexOf(".");r.push({nodeId:T.slice(0,b),message:`appointment letter bound to \`notifications.${T.slice(b+1)}\` (the standard letter, sent by code before)`})}let A=If(o).filter(T=>!T.hasTeam);for(let T of A)i.push({code:"task/userWithoutTeam",nodeId:T.nodeId,answer:"edit",message:`task \`${T.taskKey}\` names a fixed person and no team \u2014 give it a team (\`assign.group\`) by hand`});let I=_O(o);o=I.graph;for(let T of I.dropped.filter(b=>b.hasTeam))r.push({nodeId:T.nodeId,message:`task \`${T.taskKey}\`: \`assign.userId\` deleted (the team holds the row)`});let _=E_(o,{bindings:!0});o=_.graph;for(let T of _.dropped){if(!T.binding){r.push({nodeId:T.nodeId,message:`input \`${T.key}\` deleted (no slot of the node declares it)`});continue}r.push({nodeId:T.nodeId,message:`input \`${T.key}\` deleted (DEFAULT \u2014 a binding no slot declares: no slot handed its value to the node, but the readiness gate waited for it; the node no longer waits for that value)`,defaulted:{answer:"undeclaredBinding",answerKey:`${T.nodeId}.${T.key}`,value:"deleted"}})}return{graph:o,changes:r,refusals:i}}s(G_,"upgradeGraph");function LH(e){return`waitlistOrder=${e.waitlistOrder}`}s(LH,"formatPolicy");function ui(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(ui,"isObject");var z_="admission.generic",W_=Object.keys(cf).filter(e=>e!=="label");function Y_(e){return ui(e.smartforms)?Object.entries(e.smartforms):[]}s(Y_,"smartformEntries");function MH(e){let n=[];Y_(e.index).some(([,i])=>ui(i)&&"outcomeFnRef"in i)&&n.push({de:"`smartforms.<slug>.outcomeFnRef` in bundle.yaml",en:"`smartforms.<slug>.outcomeFnRef` in bundle.yaml"});let t=Object.keys(e.manifest).filter(i=>Object.hasOwn(fl,i));if(t.length>0){let i=t.map(o=>`\`${o}\``).join(", ");n.push({de:`manifest.json mit ${i}`,en:`manifest.json with ${i}`})}Object.values(e.smartforms??{}).some(i=>W_.some(o=>o in i))&&n.push({de:"Formulardateien mit `id` / `outcomeIds` / `schoolSlug`",en:"form files with `id` / `outcomeIds` / `schoolSlug`"});let r=e.workflow;return r!==void 0&&(ui(r.progressWiring)&&"layoutId"in r.progressWiring&&n.push({de:"`progressWiring.layoutId`",en:"`progressWiring.layoutId`"}),n.push(...U_(r.graph).map(i=>i.what))),n}s(MH,"legacyBundleShapes");function Sp(e,n){let t=MH(e);t.length!==0&&le("BUNDLE_NEEDS_UPGRADE",{de:`offer: ${n} stammt aus einem \xE4lteren Bundle-Format (${t.map(r=>r.de).join("; ")}). Zuerst \`plexus-cli offer upgrade --dir <Bundle>\` ausf\xFChren (Probelauf, beantwortet die offenen Fragen), dann mit \`--write\` schreiben und erneut pr\xFCfen.`,en:`offer: ${n} is in an older bundle format (${t.map(r=>r.en).join("; ")}). Run \`plexus-cli offer upgrade --dir <bundle>\` first (a dry run that asks what it cannot decide), then write with \`--write\` and validate again.`})}s(Sp,"assertBundleCurrent");function xp(e){let n=s(t=>Array.isArray(t)?t.map(n):ui(t)?Object.fromEntries(Object.keys(t).sort().map(r=>[r,n(t[r])])):t,"sort");return JSON.stringify(n(e))}s(xp,"canonical");function H_(e,n={}){let t=[],r=[],i=e.index,o=Y_(i);if(o.some(([,u])=>ui(u)&&Object.keys(u).length>0)){let u={};for(let[p,m]of o){if(!ui(m)||Object.keys(m).length===0){u[p]=m;continue}let{outcomeFnRef:y,...k}=m;if(Object.keys(k).length>0||y!==void 0&&y!==z_){r.push({file:"bundle.yaml",code:"index/smartformEntry",answer:"edit",message:`smartforms.${p} carries ${Object.keys(m).map(g=>`\`${g}\``).join(", ")} \u2014 only \`outcomeFnRef: ${z_}\` is known; edit the entry to {} by hand`}),u[p]=m;continue}t.push({file:"bundle.yaml",message:`smartforms.${p}.outcomeFnRef deleted (a form routes by its own declared outcomes)`}),u[p]={}}i={...i,smartforms:u}}let a={},l=e.workflow,d;for(let[u,p]of Object.entries(e.manifest)){if(u==="selection"){d=p,t.push({file:"manifest.json",message:"`selection` deleted (its queue policy goes to the waitlist node's inputs; release strategy and deadline were read by nothing)"});continue}if(u==="progressLayout"){l===void 0?t.push({file:"manifest.json",message:"`progressLayout` deleted (the bundle has no workflow it could belong to)"}):l.progressLayout===void 0?(l={...l,progressLayout:p},t.push({file:"manifest.json",message:"`progressLayout` moved to workflow.json `progressLayout`"})):xp(l.progressLayout)===xp(p)?t.push({file:"manifest.json",message:"`progressLayout` deleted (workflow.json carries the same layout)"}):(r.push({file:"manifest.json",code:"manifest/progressLayoutTwice",answer:"edit",message:"`progressLayout` differs from workflow.json `progressLayout` \u2014 keep one by hand"}),a[u]=p);continue}let m=Object.hasOwn(fl,u)?fl[u]:void 0;if(m===void 0){r.push({file:"manifest.json",code:"manifest/unknownKey",answer:"edit",message:`unknown key \`${u}\` \u2014 manifest.json carries no key; decide by hand where it belongs`}),a[u]=p;continue}t.push({file:"manifest.json",message:`\`${u}\` deleted (${m.en})`})}if(l!==void 0){if(ui(l.progressWiring)&&"layoutId"in l.progressWiring){let{layoutId:p,...m}=l.progressWiring;l={...l,progressWiring:m},t.push({file:"workflow.json",message:"`progressWiring.layoutId` deleted (the layout is the workflow's own)"})}let u=l.graph;if(ui(u)&&Array.isArray(u.nodes)){let p=G_(u,{selection:d,answers:n});l={...l,graph:p.graph},t.push(...p.changes.map(m=>({...m,file:"workflow.json"}))),r.push(...p.refusals.map(m=>({...m,file:"workflow.json"})))}else r.push({file:"workflow.json",code:"workflow/graphShape",answer:"edit",message:"`graph` is no object with a node list"})}let c=e.smartforms;if(c!==void 0){let u={};for(let[p,m]of Object.entries(c)){let y={...m},k=`smartforms/${p}.json`;for(let g of W_)if(g in m){if(g==="outcomeIds"){let v=Array.isArray(m.outcomes)?m.outcomes.map(E=>ui(E)?E.id:void 0):[];if(xp([...Array.isArray(m.outcomeIds)?m.outcomeIds:[]].map(String).sort())!==xp(v.map(String).sort())){r.push({file:k,code:"smartform/outcomeIdsDiffer",answer:"edit",message:"`outcomeIds` differs from the ids of `outcomes[]` \u2014 reconcile them by hand"});continue}}delete y[g],t.push({file:k,message:`\`${g}\` deleted (${cf[g].en})`})}u[p]=y}c=u}return{bundle:{index:i,manifest:a,...c!==void 0?{smartforms:c}:{},...l!==void 0?{workflow:l}:{}},changes:t,refusals:r}}s(H_,"upgradeOfferBundle");var qH={createManifest:x.workflow.createManifest,publishManifest:x.workflow.publishManifest,publishOfferInternal:x.workflow.publishOfferInternal,publishOfferExternal:x.workflow.publishOfferExternal,getOfferPublishState:x.workflow.getOfferPublishState,upsertCustomField:x.admission.upsertCustomField,upsertDerivedAttributeRule:x.admission.upsertDerivedAttributeRule,createSmartForm:x.forms.createSmartForm,getSmartFormBySlug:x.forms.getSmartFormBySlug,saveSmartFormDraft:x.forms.saveSmartFormDraft,publishSmartForm:x.forms.publishSmartForm,createWorkflow:x.workflow.createWorkflow,getWorkflowGraph:x.workflow.getWorkflowGraph,saveWorkflowDraft:x.workflow.saveWorkflowDraft,publishWorkflow:x.workflow.publishWorkflow},Rye={createManifest:rt.workflow.createManifestInternal,publishManifest:rt.workflow.publishManifestInternal,publishOfferInternal:rt.workflow.publishOfferInternalInternal,publishOfferExternal:rt.workflow.publishOfferExternalInternal,getOfferPublishState:rt.workflow.getOfferPublishStateInternal,upsertCustomField:rt.admission.upsertCustomFieldInternal,upsertDerivedAttributeRule:rt.admission.upsertDerivedAttributeRuleInternal,createSmartForm:rt.forms.createSmartFormInternal,getSmartFormBySlug:rt.forms.getSmartFormBySlugInternal,saveSmartFormDraft:rt.forms.saveSmartFormDraftInternal,publishSmartForm:rt.forms.publishSmartFormInternal,createWorkflow:rt.workflow.createWorkflowInternal,getWorkflowGraph:rt.workflow.getWorkflowGraphInternal,saveWorkflowDraft:rt.workflow.saveWorkflowDraftInternal,publishWorkflow:rt.workflow.publishWorkflowInternal};function Kw(e,n){for(let[t,r]of Object.entries(e.smartforms??{})){(r===null||typeof r!="object"||Array.isArray(r))&&le("INVALID",{de:`offer: ${n}: smartforms.${t} muss eine leere Zuordnung ({}) sein.`,en:`offer: ${n}: smartforms.${t} must be an empty mapping ({}).`});let i=Object.keys(r);if(i.length===0)continue;let o=i.map(l=>`\`${l}\``).join(", "),a=i.includes("outcomeFnRef");le("INVALID",{de:`offer: ${n}: smartforms.${t} enth\xE4lt unbekannte Schl\xFCssel ${o} \u2014 der Eintrag muss leer sein ({}).${a?" `outcomeFnRef` geh\xF6rt nicht mehr zum Bundle-Format: ein Formular entscheidet \xFCber seine eigenen Ergebnisse. Die Zeile l\xF6schen.":""}`,en:`offer: ${n}: smartforms.${t} carries unknown key(s) ${o} \u2014 the entry must be empty ({}).${a?" `outcomeFnRef` is no longer part of the bundle format: a form routes by its own declared outcomes. Delete the line.":""}`})}}s(Kw,"assertSmartformEntries");function J_(e){let n=s(t=>Array.isArray(t)?t.map(n):t&&typeof t=="object"?Object.fromEntries(Object.keys(t).sort().map(r=>[r,n(t[r])])):t,"sort");return JSON.stringify(n(e))}s(J_,"canonicalJson");function Q_(e,n){return n==null?!0:J_(e)!==J_(n)}s(Q_,"changed");async function Z_(e,n,t,r={},i=qH){let{index:o}=n;Sp({index:o,manifest:n.manifest,...n.smartforms!==void 0?{smartforms:n.smartforms}:{},...n.workflow!==void 0?{workflow:n.workflow}:{}},`bundle of ${o.slugs.manifest}`),Kw(o,`bundle of ${o.slugs.manifest}`);let a=df(n.manifest);a.length>0&&le("INVALID",{de:`offer: manifest.json von ${o.slugs.manifest} ist ung\xFCltig:
|
|
11171
11174
|
- ${a.join(`
|
|
11172
11175
|
- `)}`,en:`offer: manifest.json of ${o.slugs.manifest} is invalid:
|
|
11173
11176
|
- ${a.join(`
|
|
@@ -11195,7 +11198,7 @@ Ihr Aufnahme-Team`,noReplyNote:"Diese E-Mail wurde automatisch versandt. Bitte a
|
|
|
11195
11198
|
The admissions team`,noReplyNote:"This e-mail was sent automatically. Please do not reply to it."}},_J={de:{...Ql.de,closing:`Viele Gr\xFC\xDFe
|
|
11196
11199
|
Ihr Plexus-Team`},en:{...Ql.en,closing:`Kind regards
|
|
11197
11200
|
The Plexus team`}},CJ={de:{...Ql.de,closing:null},en:{...Ql.en,closing:null}};var DJ=/\{\{([a-zA-Z][a-zA-Z0-9_]*)\}\}/g,Fo=2e3;function jp(e){let n=[];for(let t of e.matchAll(DJ)){let r=t[1];n.includes(r)||n.push(r)}return n}s(jp,"placeholdersIn");function aD(e){return e.slots??[]}s(aD,"slotsOf");function FJ(e){return e.bodyVariants!==void 0?e.bodyVariants:[aD(e).filter(n=>n.key!==El).map(n=>n.key)]}s(FJ,"bodyVariantsOf");var LJ=/:\/\/|www\.|mailto:/i;function MJ(e,n){let t=`{{${n}}}`,r=0;for(;;){let i=e.indexOf(t,r);if(i===-1)return!1;let o=i===0?"":e[i-1],a=e[i+t.length]??"";if(o!==""&&!/\s/.test(o)||a!==""&&!/[\s.,;:!?)]/.test(a))return!0;r=i+t.length}}s(MJ,"linkGlued");function qJ(e,n){let t=e.default[n];return(typeof t!="string"||t.length===0)&&F(`notifications: slot "${e.key}" has no "${n}" text`),t}s(qJ,"defaultText");function lD(e,n,t){let r=[],i=aD(e),o=e.placeholders??[],a=o.map(u=>u.key),l=o.filter(u=>u.subjectSafe===!0).map(u=>u.key);for(let[u,p]of Object.entries(n)){let m=i.find(y=>y.key===u);if(m===void 0){r.push({slotKey:u,code:"unknownSlot",message:i.length===0?{de:`Der Brief \u201E${e.label}\u201C l\xE4sst sich nicht anpassen.`,en:`The letter "${e.label}" cannot be customized.`}:{de:`Der Baustein \u201E${u}\u201C geh\xF6rt nicht zum Brief \u201E${e.label}\u201C.`,en:`The block "${u}" does not belong to the letter "${e.label}".`}});continue}if(p.trim().length===0){r.push({slotKey:u,code:"empty",message:{de:`\u201E${m.label}\u201C darf nicht leer sein. Zum Entfernen den Baustein zur\xFCcksetzen.`,en:`"${m.label}" must not be empty. To remove it, reset the block.`}});continue}if(p.length>Fo){r.push({slotKey:u,code:"tooLong",message:{de:`\u201E${m.label}\u201C ist ${p.length} Zeichen lang, erlaubt sind ${Fo}.`,en:`"${m.label}" is ${p.length} characters long; the limit is ${Fo}.`}});continue}if(hP(e)){LJ.test(p)&&r.push({slotKey:u,code:"foreignUrl",message:{de:`\u201E${m.label}\u201C enth\xE4lt eine Adresse. Der Brief \u201E${e.label}\u201C tr\xE4gt einen Anmeldeschl\xFCssel und darf keine weiteren Links enthalten.`,en:`"${m.label}" contains an address. The letter "${e.label}" carries a sign-in key and must not contain any further links.`}});for(let y of o)y.link!==!0||!MJ(p,y.key)||r.push({slotKey:u,code:"linkNotStandalone",message:{de:`\u201E{{${y.key}}}\u201C (${y.label}) muss f\xFCr sich stehen \u2014 davor und dahinter nur ein Leerzeichen, ein Zeilenumbruch oder ein Satzzeichen.`,en:`"{{${y.key}}}" (${y.label}) must stand on its own \u2014 only a space, a line break or punctuation before and after it.`}})}for(let y of jp(p)){if(!a.includes(y)){r.push({slotKey:u,code:"unknownPlaceholder",message:y===jr?{de:`\u201E{{${jr}}}\u201C (${fa}) geh\xF6rt in die Anrede des Briefrahmens, nicht in \u201E${m.label}\u201C \u2014 dort gibt es eine neutrale Anrede, wenn kein Name bekannt ist.`,en:`"{{${jr}}}" (${fa}) belongs in the greeting of the letter frame, not in "${m.label}" \u2014 the greeting has a neutral form for when no name is known.`}:a.length===0?{de:`Der Brief \u201E${e.label}\u201C kennt keine Platzhalter, \u201E{{${y}}}\u201C bliebe unersetzt stehen.`,en:`The letter "${e.label}" has no placeholders; "{{${y}}}" would stay in the text unreplaced.`}:{de:`\u201E{{${y}}}\u201C gibt es in \u201E${e.label}\u201C nicht. Erlaubt: ${a.map(g=>`{{${g}}}`).join(", ")}.`,en:`"{{${y}}}" does not exist in "${e.label}". Allowed: ${a.map(g=>`{{${g}}}`).join(", ")}.`}});continue}if(u!==El||l.includes(y))continue;let k=o.find(g=>g.key===y)?.label??y;r.push({slotKey:u,code:"subjectUnsupported",message:{de:`\u201E{{${y}}}\u201C (${k}) l\xE4sst sich im Betreff nicht einsetzen \u2014 der Wert entsteht erst beim Versand. `+(l.length===0?"In diesem Brief kann der Betreff keine Platzhalter tragen.":`Im Betreff m\xF6glich: ${l.map(g=>`{{${g}}}`).join(", ")}.`),en:`"{{${y}}}" (${k}) cannot be used in the subject \u2014 the value only exists when the mail is sent. `+(l.length===0?"In this letter the subject cannot carry placeholders.":`Possible in the subject: ${l.map(g=>`{{${g}}}`).join(", ")}.`)}})}}let d=s(u=>n[u]??KJ(i,u,t),"textOf"),c=FJ(e);for(let u of o){if(u.required!==!0)continue;let p=c.filter(g=>!jp(g.map(d).join(`
|
|
11198
|
-
`)).includes(u.key));if(p.length===0)continue;let m=s((g,v)=>g.map(E=>v(i.find(A=>A.key===E)?.label??E)).join(" + "),"variantLabel"),y=c.length===1?"":` Er fehlt in der Fassung aus ${p.map(g=>m(g,v=>`\u201E${v}\u201C`)).join(" und in der aus ")}.`,k=c.length===1?"":` It is missing in the version made of ${p.map(g=>m(g,v=>`"${v}"`)).join(" and in the one made of ")}.`;r.push({slotKey:u.key,code:"missingRequired",message:{de:`Ohne \u201E{{${u.key}}}\u201C (${u.label}) funktioniert der Brief \u201E${e.label}\u201C nicht \u2014 der Platzhalter muss im Text stehen, nicht nur im Betreff.`+y,en:`Without "{{${u.key}}}" (${u.label}) the letter "${e.label}" does not work \u2014 the placeholder must be in the text, not only in the subject.`+k}})}return r}s(lD,"validateOverride");function KJ(e,n,t){let r=e.find(i=>i.key===n);return r===void 0?"":qJ(r,t)}s(KJ,"defaultTextOf");function Sk(e){let n=e?.trim();return n===void 0||n.length===0?void 0:n}s(Sk,"normalizeChromeText");var Lo=s(e=>String.fromCharCode(e),"cp"),jJ=new RegExp(`[${Lo(0)}-${Lo(31)}${Lo(127)}]`,"g"),BJ=new RegExp(`[${Lo(8234)}-${Lo(8238)}${Lo(8294)}-${Lo(8297)}]`,"g");var VJ=200;function UJ(e,n=VJ){return e.replace(jJ," ").replace(BJ,"").replace(/\s+/g," ").trim().slice(0,n)}s(UJ,"sanitizeHeaderValue");function Bp(e){return UJ(e.replace(/["<>@]/g,""),100)}s(Bp,"sanitizeDisplayName");var Ak={de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}},GJ={greeting:{de:"Anrede",en:"Greeting"},closing:{de:"Gru\xDFformel",en:"Closing"}};function dD(e){let n=[],t=[];for(let i of["greeting","closing"]){let o=e[i];if(o===void 0)continue;let a=GJ[i],l=Rn(o);l!=="not-localized"&&l.length>0&&l.length<We.length&&t.push({de:`${a.de} fehlt auf ${l.map(d=>Ak[d].de).join(" und ")}`,en:`${a.en} is missing in ${l.map(d=>Ak[d].en).join(" and ")}`});for(let d of We){let c=Jy(m=>`${a[m]} (${Ak[d][m]})`),u=Sk(o[d]);u!==void 0&&u.length>Fo&&n.push({de:`${c.de} hat ${u.length} Zeichen \u2014 h\xF6chstens ${Fo}; der Briefrahmen ist eine Zeile der Mail, kein Dokument.`,en:`${c.en} has ${u.length} characters \u2014 at most ${Fo}; the letter frame is one line of the mail, not a document.`});let p=i==="greeting"?[jr]:[];for(let m of jp(u??""))p.includes(m)||n.push(p.length===0?{de:`${c.de} kann keine Platzhalter tragen \u2014 \u201E{{${m}}}\u201C bliebe unersetzt stehen.`,en:`${c.en} cannot carry placeholders \u2014 "{{${m}}}" would stay in the text unreplaced.`}:{de:`\u201E{{${m}}}\u201C gibt es in der ${c.de} nicht. Erlaubt: {{${jr}}} (${fa}).`,en:`"{{${m}}}" does not exist in the ${c.en}. Allowed: {{${jr}}} (${fa}).`})}}t.length>0&&n.unshift({de:`[notification/chromeMissingTranslation] ${t.map(i=>i.de).join("; ")} \u2014 der Briefrahmen gilt f\xFCr jeden Brief, in jeder Sprache.`,en:`[notification/chromeMissingTranslation] ${t.map(i=>i.en).join("; ")} \u2014 the letter frame applies to every letter, in every language.`});let r=Sk(e.senderName);return r!==void 0&&Bp(r)!==r&&n.push({de:`Absendername (senderName) \u201E${r}\u201C \xFCbersteht die Kopfzeile der Mail nicht unver\xE4ndert \u2014 er ginge als \u201E${Bp(r)}\u201C hinaus. Keine Anf\xFChrungszeichen, spitzen Klammern, \u201E@\u201C oder Steuerzeichen.`,en:`The sender name (senderName) "${r}" does not survive the mail header unchanged \u2014 it would go out as "${Bp(r)}". No quotation marks, angle brackets, "@" or control characters.`}),n}s(dD,"chromeFindings");var cD=w.object({family:w.string()}),uD=w.object({family:w.string(),url:w.optional(w.string())}),qve=w.object({heading:w.optional(uD),body:w.optional(uD)}),zJ=w.union(w.literal("sharp"),w.literal("rounded"),w.literal("soft")),WJ=w.union(w.literal("light"),w.literal("dark")),YJ=w.union(w.literal("sm"),w.literal("md"),w.literal("lg"),w.literal("max")),HJ=w.union(w.literal("compact"),w.literal("normal"),w.literal("spacious")),JJ=w.object({primary:w.optional(w.string()),accent:w.optional(w.string()),background:w.optional(w.string()),foreground:w.optional(w.string())}),QJ=w.object({heading:w.optional(cD),body:w.optional(cD)}),Kve=w.object({colors:w.optional(JJ),radius:w.optional(zJ),logoSize:w.optional(YJ),bannerDensity:w.optional(HJ),logoGround:w.optional(WJ),filledHeader:w.optional(w.boolean()),websiteUrl:w.optional(w.string()),fonts:w.optional(QJ)}),jve=w.object({primaryUrl:w.union(w.null(),w.string())}),Bve=w.literal("primary"),Vve=w.object({headingUrl:w.union(w.null(),w.string()),bodyUrl:w.union(w.null(),w.string())}),Uve=w.union(w.literal("heading"),w.literal("body")),Vp=["logo","fontHeading","fontBody"],fD={logo:null,fontHeading:"heading",fontBody:"body"};function pD(e){let{contentType:n,size:t}=e;return n==null||!n.startsWith("image/")?{de:`Das Logo muss ein Bild sein (erhalten: \u201E${n??"unbekannt"}\u201C).`,en:`The logo must be an image (received: "${n??"unknown"}").`}:n.startsWith("image/svg")?{de:"Das Logo muss eine Rastergrafik sein (PNG, JPEG oder GIF) \u2013 E-Mail-Programme zeigen SVG nicht an.",en:"The logo must be a raster image (PNG, JPEG or GIF) \u2013 email clients do not display SVG."}:t>3e6?{de:`Das Logo ist zu gro\xDF (${t} Byte, h\xF6chstens 3000000 Byte).`,en:`The logo is too large (${t} bytes, at most 3000000 bytes).`}:null}s(pD,"logoFileProblem");var Ek="font/woff2";var ZJ=["Inter Variable","Azeret Mono Variable","Source Sans 3 Variable"];function mD(e){return e?.trim()?ZJ.some(n=>n.toLowerCase()===e.trim().toLowerCase())?{de:`\u201E${e}\u201C ist die Schrift von Plexus selbst \u2013 w\xE4hlen Sie f\xFCr eine eigene Datei einen anderen Familiennamen.`,en:`"${e}" is Plexus's own typeface \u2013 choose a different family name for your own file.`}:null:{de:"Speichern Sie zuerst die Schriftfamilie \u2013 die Datei wird unter diesem Namen eingebunden.",en:"Save the font family first \u2013 the file is registered under that name."}}s(mD,"fontFamilyProblem");var XJ=["approved","rejected","withdrawn","waitlist","expired"];var Up=["admitted","rejected","withdrawn","waitlist","expired","unknown"],Qve=w.union(...XJ.map(e=>w.literal(e))),Zve=w.union(...Up.map(e=>w.literal(e))),e6=["approved","rejected","waitlist"],n6=["withdrawn","expired"],t6=w.union(...e6.map(e=>w.literal(e))),r6=w.union(...n6.map(e=>w.literal(e))),Xve={active:{status:w.literal("active")},completed:{status:w.literal("completed"),outcome:t6,endedAt:w.number()},aborted:{status:w.literal("aborted"),outcome:w.optional(r6),endedAt:w.number()}};var hD=30,gD=3650;var i6=w.object({admitted:w.optional(w.number()),rejected:w.optional(w.number()),withdrawn:w.optional(w.number()),expired:w.optional(w.number()),waitlist:w.optional(w.number()),unknown:w.optional(w.number())}),oxe=i6.fields,o6=s(e=>Up.includes(e),"isClassification");function yD(e,n="tenant.retentionDays"){if(e===null||typeof e!="object"||Array.isArray(e))return[`[retention/shape] ${n} must be an object of days per classification (got ${JSON.stringify(e)}).`];let t=[];for(let[r,i]of Object.entries(e)){if(!o6(r)){t.push(`[retention/unknownClassification] ${n}.${r} is no retention classification \u2014 one of ${Up.join(", ")}.`);continue}(typeof i!="number"||!Number.isSafeInteger(i)||i<hD||i>gD)&&t.push(`[retention/days] ${n}.${r} must be a whole number of days from ${hD} to ${gD} (got ${JSON.stringify(i)}).`)}return t}s(yD,"retentionDaysFindings");var s6=["ad","ae","af","ag","ai","al","am","ao","aq","ar","as","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bl","bm","bn","bo","bq","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","cr","cu","cv","cw","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","eh","er","es","et","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mf","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","ss","st","sv","sx","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tr","tt","tv","tw","tz","ua","ug","um","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","xk","ye","yt","za","zm","zw"],a6=new Set(s6);function Gp(e){return a6.has(e)}s(Gp,"isCountryCode");var Tk=["off","always","deviating"],wD={mode:"deviating",defaultCountryCode:"de"};var l6=["street","plz","ort"];function d6(e){return l6.filter(n=>!e.has(n))}s(d6,"missingInvoiceAddressParts");var c6=new Set(["0-1-select","0-n-select"]);function kD(e){return e===void 0?null:new Set(e.properties.flatMap(n=>n.addressPart!==void 0&&SO(n.addressPart)?[n.addressPart]:[]))}s(kD,"declaredAddressParts");function u6(e){return c6.has(e)}s(u6,"isSelectFieldKind");function bD(e){let n=[];for(let o of e)if(o.isNationality&&(u6(o.kind)?o.listKind!=="country"&&n.push({code:"nationality/notCountryList",fieldKey:o.key}):n.push({code:"nationality/wrongFieldKind",fieldKey:o.key})),o.isAccountEmail&&o.kind!=="email"&&n.push({code:"accountEmail/wrongFieldKind",fieldKey:o.key}),o.isContactPhone&&o.kind!=="tel"&&n.push({code:"contactPhone/wrongFieldKind",fieldKey:o.key}),o.isInvoiceAddress)if(o.addressParts===null)n.push({code:"invoiceAddress/wrongFieldKind",fieldKey:o.key});else{let a=d6(o.addressParts);a.length>0&&n.push({code:"invoiceAddress/missingPart",fieldKey:o.key,parts:a})}let t=e.filter(o=>o.isAccountEmail);if(t.length>1)for(let o of t)n.push({code:"accountEmail/multiple",fieldKey:o.key});let r=e.filter(o=>o.isContactPhone);if(r.length>1)for(let o of r)n.push({code:"contactPhone/multiple",fieldKey:o.key});let i=e.filter(o=>o.isInvoiceAddress);if(i.length>1)for(let o of i)n.push({code:"invoiceAddress/multiple",fieldKey:o.key});return n}s(bD,"fieldRoleFindings");function vD(e,n,...t){let r=e[n.code];return r(n,...t)}s(vD,"wordListElementFinding");function xD(e,n){let t=[];for(let r of n){if(e.kind==="plain"){r.countryCode!==void 0&&t.push({code:"list/countryCodeOnPlain",elementKey:r.key,countryCode:r.countryCode});continue}r.countryCode===void 0?t.push({code:"list/countryCodeMissing",elementKey:r.key}):r.countryCode!==null&&!Gp(r.countryCode)&&t.push({code:"list/unknownCountryCode",elementKey:r.key,countryCode:r.countryCode})}return t}s(xD,"listElementCountryFindings");var p6={key:!0,tenant:!0,foundation:!0,source:!0,displayGroups:!0,lists:!0,roles:!0,fields:!0,roleFields:!0,contractRoleMappings:!0,templatePlaceholders:!0,searchTargets:!0,searchFilters:!0,partyResultIcons:!0,notificationLetters:!0,admission:!0,files:!0,agent:!0,deferredColumns:!0,ignoredColumns:!0},m6={slug:!0,name:!0,enabledModules:!0,permissions:!0,defaultApplicantGroupKey:!0,defaultEnrolleeRoleKey:!0,priceCriteriaFacts:!0,defaultInteressentRoleKey:!0,admissionFieldDisplayGroupKey:!0,defaultStartInProxy:!0,terms:!0,retentionDays:!0,mailLevel:!0,notificationChrome:!0,hideMailLevelNotice:!0,magicLinkLogin:!0,externalSignIn:!0,nationalityFlag:!0,adminSeesSignatureImages:!0,signatureStamp:!0,bankImportScope:!0,branding:!0,brandingAssets:!0,partyRetention:!0},h6=new Set(["enabledMailCategories","mailEnabled"]);function g6(e){let n=s((t,r,i)=>t.filter(o=>!Object.hasOwn(r,o)&&!(i==="tenant."&&h6.has(o))).map(o=>`[config/unknownKey] ${i}${o} is not a config field of this release \u2014 a typo, or a field a newer release introduced.`),"unknown");return[...n(Object.keys(e),p6,""),...n(Object.keys(e.tenant),m6,"tenant.")]}s(g6,"unknownKeyFindings");var SD=["plain","country"],y6={"list/countryCodeMissing":s(({elementKey:e},n)=>`Element "${n}.${e}" of a country list must state countryCode (null for no state).`,"list/countryCodeMissing"),"list/countryCodeOnPlain":s(({elementKey:e},n)=>`Element "${n}.${e}" carries countryCode, but list "${n}" is not kind "country".`,"list/countryCodeOnPlain"),"list/unknownCountryCode":s(({elementKey:e,countryCode:n},t)=>`Element "${t}.${e}" has unknown countryCode ${JSON.stringify(n)}.`,"list/unknownCountryCode")},w6={"nationality/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isNationality but not a 0-1-select / 0-n-select.`,"nationality/wrongFieldKind"),"nationality/notCountryList":s(({fieldKey:e})=>`Field "${e}" is isNationality but its list is not kind "country".`,"nationality/notCountryList"),"accountEmail/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isAccountEmail but not an email field.`,"accountEmail/wrongFieldKind"),"accountEmail/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isAccountEmail fields \u2014 at most one per tenant.`,"accountEmail/multiple"),"contactPhone/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isContactPhone but not a tel field.`,"contactPhone/wrongFieldKind"),"contactPhone/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isContactPhone fields \u2014 at most one per tenant.`,"contactPhone/multiple"),"invoiceAddress/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isInvoiceAddress but not an object field.`,"invoiceAddress/wrongFieldKind"),"invoiceAddress/missingPart":s(({fieldKey:e,parts:n})=>`Field "${e}" is isInvoiceAddress but declares no property for the address part(s) ${n.join(", ")} (objectSchema.properties[].addressPart) \u2014 an invoice cannot print its address without them.`,"invoiceAddress/missingPart"),"invoiceAddress/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isInvoiceAddress fields \u2014 at most one per tenant.`,"invoiceAddress/multiple")};function k6(e){let n=w6[e.code];return n(e)}s(k6,"roleText");function b6(e){let n=[],t=e.tenant.nationalityFlag,r=typeof t=="object"&&t!==null?t:{},i=r.mode;if(Tk.includes(i)||n.push(`[nationality/flagMode] tenant.nationalityFlag.mode must be one of ${Tk.join(", ")} (got ${t===void 0?"no tenant.nationalityFlag":JSON.stringify(i??null)}).`),t!==void 0){let l=r.defaultCountryCode;(typeof l!="string"||!Gp(l))&&n.push(`[nationality/defaultCountryCode] tenant.nationalityFlag.defaultCountryCode must be a lowercase ISO 3166-1 alpha-2 code (got ${JSON.stringify(l??null)}).`)}let o=new Map;for(let l of e.lists){let d=l.kind;if(!SD.includes(d)){n.push(`[list/kind] List "${l.key}" has kind ${JSON.stringify(d??null)} \u2014 one of ${SD.join(", ")}.`);continue}o.set(l.key,l.kind);for(let c of xD({key:l.key,kind:l.kind},l.elements))n.push(`[${c.code}] ${vD(y6,c,l.key)}`)}let a=bD(e.fields.map(l=>({key:l.key,kind:l.type,listKind:l.listKey===void 0?null:o.get(l.listKey)??null,isNationality:l.isNationality===!0,isAccountEmail:l.isAccountEmail===!0,isContactPhone:l.isContactPhone===!0,isInvoiceAddress:l.isInvoiceAddress===!0,addressParts:l.type==="object"?kD(l.objectSchema??{properties:[]}):null})));for(let l of a)n.push(`[${l.code}] ${k6(l)}`);return n}s(b6,"nationalityFindings");function AD(e){return vi(e)?.message.de??(e instanceof Error?e.message:String(e))}s(AD,"errorText");function $D(e,n={}){let t=[...g6(e)],r=[];try{JC(e.fields.map(b=>b.key),[])}catch(b){t.push(AD(b))}e.tenant.terms!==void 0&&t.push(...xk(e.tenant.terms)),e.tenant.retentionDays!==void 0&&t.push(...yD(e.tenant.retentionDays)),mP(e.tenant.mailLevel)?e.tenant.mailLevel==="all"&&!Lp(e.tenant.enabledModules,"notifications")&&t.push('[notification/levelWithoutModule] tenant.mailLevel is "all" but the notifications module is not enabled \u2014 only sign-in and security mail would go out. Enable the module or set "loginOnly".'):t.push(`[notification/mailLevel] tenant.mailLevel must be one of ${ew.join(", ")} (got ${e.tenant.mailLevel===void 0?"nothing":JSON.stringify(e.tenant.mailLevel)}).`),"enabledMailCategories"in e.tenant&&t.push('[notification/mailCategoriesRetired] tenant.enabledMailCategories was replaced by tenant.mailLevel \u2014 "all" for every mail, "loginOnly" for sign-in mail only to families (staff mail follows personal settings).'),"mailEnabled"in e.tenant&&t.push('[notification/mailEnabledRetired] tenant.mailEnabled was replaced by tenant.mailLevel \u2014 "all" for every mail, "loginOnly" for sign-in mail only to families (staff mail follows personal settings).'),Tn(e.displayGroups.map(b=>b.key),"display group",t),Tn(e.lists.map(b=>b.key),"list",t),Tn(e.roles.map(b=>b.key),"role",t),Tn(e.fields.map(b=>b.key),"field",t),Tn(e.foundation.legalEntities.map(b=>b.key),"legal entity",t),Tn(e.foundation.units.map(b=>b.key),"unit",t),Tn(e.foundation.permissionGroups.map(b=>b.key),"permission group",t),"teams"in e.foundation&&t.push("foundation.teams is retired: a team is a permission group \u2014 move each team to foundation.permissionGroups (same key) and remove the block.");for(let b of e.foundation.users)"teamKeys"in b&&t.push(`User "${b.email}" carries teamKeys, retired: team membership is the user's permission-group membership.`);Tn(e.foundation.users.map(b=>b.key),"user",t),Tn((e.searchFilters??[]).map(b=>b.key),"search filter",t),Tn((e.searchTargets??[]).map(b=>b.objectPropertyKey===void 0?b.fieldKey:`${b.fieldKey}.${b.objectPropertyKey}`),"search target",t),Tn((e.partyResultIcons??[]).map(b=>b.key),"party result icon",t),Tn((e.templatePlaceholders??[]).map(b=>b.key),"template placeholder",t),Tn((e.notificationLetters??[]).map(RD),"notification letter",t),R6(e.notificationLetters??[],t),I6(e.tenant.notificationChrome,t),e.tenant.bankImportScope!==void 0&&!["sepa_only","full_statement"].includes(e.tenant.bankImportScope)&&t.push("tenant.bankImportScope must be sepa_only or full_statement."),e.tenant.hideMailLevelNotice!==void 0&&typeof e.tenant.hideMailLevelNotice!="boolean"&&t.push("tenant.hideMailLevelNotice must be true or false (the dashboard's mail-level notice)."),typeof e.tenant.magicLinkLogin!="boolean"&&t.push("tenant.magicLinkLogin must be true or false (the login page's sign-in link option)."),typeof e.tenant.adminSeesSignatureImages!="boolean"&&t.push("tenant.adminSeesSignatureImages must be true or false (whether a school administrator sees other accounts' signature images)."),typeof e.tenant.signatureStamp!="boolean"&&t.push("tenant.signatureStamp must be true or false (whether the school offers the signature stamp at the countersignature)."),WC(e.tenant.externalSignIn)?t.push(`[auth/externalSignInRetired] tenant.externalSignIn names the retired mode "${String(e.tenant.externalSignIn.mode)}" \u2014 every sign-in link now signs in once; state { mode: "oneTimeLink" }.`):zC(e.tenant.externalSignIn)||t.push('[auth/externalSignIn] tenant.externalSignIn must be { mode: "oneTimeLink" } (how families sign in).');let i=new Set(e.displayGroups.map(b=>b.key)),o=new Set(e.lists.map(b=>b.key)),a=new Set(e.roles.map(b=>b.key)),l=new Set(e.fields.map(b=>b.key)),d=new Map(e.fields.map(b=>[b.key,b])),c=new Set(e.foundation.legalEntities.map(b=>b.key)),u=new Set(e.foundation.units.map(b=>b.key)),p=new Set(e.foundation.permissionGroups.map(b=>b.key));Lp(e.tenant.enabledModules,"bewerbungsmanagement")&&e.tenant.defaultApplicantGroupKey!==void 0&&(e.foundation.permissionGroups.find(R=>R.key===e.tenant.defaultApplicantGroupKey)?.permissions.includes("bewerbungsmanagement.applications.submitOwn")||t.push(`Default applicant group "${e.tenant.defaultApplicantGroupKey}" must grant submitOwn.`));let m=e.tenant.admissionFieldDisplayGroupKey;m!==void 0&&!i.has(m)&&t.push(`tenant.admissionFieldDisplayGroupKey "${m}" names no display group of this config.`),m===void 0&&(Lp(e.tenant.enabledModules,"bewerbungsmanagement")||(e.admission?.fields.length??0)>0)&&t.push("tenant.admissionFieldDisplayGroupKey is required when admissions is enabled or admission.fields declares fields: it names the display group the fields an offer creates land in."),t.push(...b6(e)),Tn(e.fields.flatMap(b=>(b.relationshipKinds??[]).map(R=>R.key)),"relationship kind",t);for(let b of e.fields){i.has(b.displayGroupKey)||t.push(`Field "${b.key}" references missing display group "${b.displayGroupKey}".`),x6(b,t),b.formWritable===!0&&!kk[b.type].fieldMapTarget&&t.push(`Field "${b.key}" is formWritable, but a form cannot write a "${b.type}" field.`),b.type==="files"&&b.shareable===!0&&t.push(`[field/filesShareable] Field "${b.key}" is a files field and cannot be shareable.`),b.type==="auto-string"?S6(b,d,t):b.autoString!==void 0&&t.push(`Non-automatic field "${b.key}" must not define autoString.`),(!Number.isFinite(b.sortOrder)||b.sortOrder<0)&&t.push(`Field "${b.key}" has invalid sortOrder "${b.sortOrder}" (must be a non-negative number).`),(b.type==="0-1-select"||b.type==="0-n-select")&&!b.listKey&&t.push(`Select field "${b.key}" must define listKey.`),b.type!=="0-1-select"&&b.type!=="0-n-select"&&b.listKey!==void 0&&t.push(`Non-select field "${b.key}" must not define listKey.`),b.listKey&&!o.has(b.listKey)&&t.push(`Field "${b.key}" references missing list "${b.listKey}".`),(b.type==="object"||b.type==="relationship")&&!b.objectSchema&&t.push(`Field "${b.key}" must define objectSchema.`),b.type!=="object"&&b.type!=="relationship"&&b.objectSchema&&t.push(`Non-object field "${b.key}" must not define objectSchema.`);for(let R of b.objectSchema?.properties??[])(R.type==="0-1-select"||R.type==="0-n-select")&&!R.listKey&&t.push(`Object select property "${b.key}.${R.key}" must define listKey.`),R.listKey&&!o.has(R.listKey)&&t.push(`Object property "${b.key}.${R.key}" references missing list "${R.listKey}".`);v6(b,t)}let y=e.tenant.priceCriteriaFacts;if(y){let b=e.fields.find(R=>R.key===y.birthDateFieldKey);(!b||b.type!=="date")&&t.push("Price criteria require a configured date field for birth dates."),a.has(y.studentRoleKey)||t.push("Price criteria require a configured Student eligibility role."),y.siblingRankSource!==void 0&&y.siblingRankSource!=="derived"&&y.siblingRankSource!=="chosen"&&t.push('Price criteria siblingRankSource must be "derived" or "chosen".');for(let R of Object.keys(y))R!=="birthDateFieldKey"&&R!=="studentRoleKey"&&R!=="siblingRankSource"&&t.push(`Unknown price criteria fact setting "${R}".`)}let k=e.tenant.defaultEnrolleeRoleKey;k&&!a.has(k)&&t.push(`Default enrollment role "${k}" does not exist.`),k&&e.roles.some(b=>b.parentRoleKey===k)&&t.push(`Default enrollment role "${k}" must be a leaf role.`);for(let b of e.roles){(typeof b.icon!="string"||b.icon.trim().length===0)&&t.push(`Role "${b.key}" must define an icon.`),b.parentRoleKey&&!a.has(b.parentRoleKey)&&t.push(`Role "${b.key}" references missing parent role "${b.parentRoleKey}".`);for(let R of b.listDisplayFieldKeys??[])l.has(R)||t.push(`Role "${b.key}" list display references missing field "${R}".`)}let g=new Map(e.roles.map(b=>[b.key,b.parentRoleKey])),v=new Map;for(let b of e.roleFields){let R=v.get(b.roleKey)??[];R.push({roleId:b.roleKey,customFieldId:b.fieldKey}),v.set(b.roleKey,R)}for(let b of e.roles)try{YC(b.key,g,v)}catch(R){t.push(AD(R))}for(let b of e.roleFields){a.has(b.roleKey)||t.push(`Role field references missing role "${b.roleKey}" for field "${b.fieldKey}".`),l.has(b.fieldKey)||t.push(`Role field references missing field "${b.fieldKey}" for role "${b.roleKey}".`);for(let R of b.targetRequirementFieldKeys??[])l.has(R)||t.push(`Role field "${b.roleKey}.${b.fieldKey}" references missing target requirement field "${R}".`)}$6(e.contractRoleMappings??[],a,t);for(let b of e.templatePlaceholders??[])AC.test(b.key)||t.push(`Template placeholder "${b.key}" must use lower_snake_case segments, optionally separated by dots.`),b.source.kind==="customField"?zp(b.source,d,t,`Template placeholder "${b.key}"`):b.source.kind==="relationshipTargetField"&&A6(b,d,t);for(let b of e.searchTargets??[])zp(b,d,t,"Search target");for(let b of e.fields)nD(b.key)&&(b.defaultValue!==void 0||b.validations!==void 0)&&t.push(`System field "${b.key}" takes no defaultValue or validations.`);for(let b of e.lists)Tn(b.elements.map((R,q)=>String(R.sortOrder??(q+1)*10)),`sortOrder of an element of list "${b.key}"`,t);for(let b of e.searchFilters??[])Tn((b.options??[]).map((R,q)=>String(R.sortOrder??(q+1)*10)),`sortOrder of an option of search filter "${b.key}"`,t);for(let b of e.foundation.permissionGroups){b.grantAllCustomFields===!0&&b.customFieldPermissions!==void 0&&t.push(`Permission group "${b.key}" states both grantAllCustomFields and customFieldPermissions \u2014 one of them.`),Tn((b.customFieldPermissions??[]).map(R=>R.displayGroupKey),`display group of a field permission of group "${b.key}"`,t);for(let R of b.customFieldPermissions??[]){i.has(R.displayGroupKey)||t.push(`Permission group "${b.key}" grants field permissions on missing display group "${R.displayGroupKey}".`);for(let q of R.permissions)ZC.includes(q)||t.push(`Permission group "${b.key}" grants unknown field permission "${q}".`)}}let E=e.tenant.partyRetention;E!==void 0&&(eD(E.days)||t.push(`tenant.partyRetention.days must be a whole number of days from 1 to ${36500} (got ${JSON.stringify(E.days)}).`),Number.isFinite(E.enabledAt)||t.push("tenant.partyRetention.enabledAt must be a timestamp (epoch ms)."),E.formerRoleKey!==void 0&&!a.has(E.formerRoleKey)&&t.push(`tenant.partyRetention references missing role "${E.formerRoleKey}".`));for(let b of e.searchFilters??[]){(b.kind==="chips"||b.kind==="select")&&(b.options?.length??0)===0&&t.push(`Search filter "${b.key}" must define options.`),(b.kind==="text"||b.kind==="numberRange")&&b.target===void 0&&t.push(`Search filter "${b.key}" must define a target field.`),b.options!==void 0&&Tn(b.options.map(R=>R.key),`search filter option for "${b.key}"`,t),zp(b.target,d,t,`Search filter "${b.key}"`);for(let R of b.options??[]){R.predicates.length===0&&t.push(`Search filter option "${b.key}.${R.key}" must define at least one predicate.`);for(let q of R.predicates){if(q.kind==="role"){a.has(q.roleKey)||t.push(`Search filter option "${b.key}.${R.key}" references missing role "${q.roleKey}".`);continue}zp(q,d,t,`Search filter option "${b.key}.${R.key}"`)}}}for(let b of e.partyResultIcons??[])E6(b,d,t);for(let b of e.foundation.legalEntities)if(b.terms!==void 0&&t.push(...xk(b.terms,`foundation.legalEntities.${b.key}.terms`)),ED(b.branding,t,`foundation.legalEntities.${b.key}.branding`),TD(b,t,`foundation.legalEntities.${b.key}`),b.signatoryUserKey!==void 0&&b.type==="school_group"&&t.push(`[config/signatoryOnGroup] Legal entity "${b.key}" is a school_group \u2014 only a Tr\xE4ger (school_operator, service_entity) declares an Unterschriftsperson.`),b.parentLegalEntityKey&&!c.has(b.parentLegalEntityKey)&&t.push(`Legal entity "${b.key}" references missing parent "${b.parentLegalEntityKey}".`),b.address!==void 0){let R=b.address,q=["street","hausnr","plz","ort"];b.type==="school_group"?t.push(`Legal entity "${b.key}" is a school_group \u2014 only a Tr\xE4ger (school_operator, service_entity) has an address.`):(typeof R!="object"||R===null||Array.isArray(R)||Object.keys(R).some(P=>!q.includes(P))||q.some(P=>typeof R[P]!="string"||(R[P]??"").trim()===""))&&t.push(`Legal entity "${b.key}" has an invalid address \u2014 expected { street, hausnr, plz, ort }, each non-empty.`)}let A=new Map;for(let b of e.foundation.units){if(b.slug!==void 0){let R=typeof b.slug=="string"?FC(b.slug):"must be a string";R!==void 0&&t.push(`Unit "${b.key}" has invalid slug "${b.slug}" (${R}).`);let q=A.get(b.slug);q!==void 0&&t.push(`Units "${q}" and "${b.key}" both declare slug "${b.slug}" (unit slugs are unique per tenant).`),A.set(b.slug,b.key)}c.has(b.legalEntityKey)||t.push(`Unit "${b.key}" references missing legal entity "${b.legalEntityKey}".`),b.parentUnitKey&&!u.has(b.parentUnitKey)&&t.push(`Unit "${b.key}" references missing parent unit "${b.parentUnitKey}".`),b.sortOrder!==void 0&&(!Number.isFinite(b.sortOrder)||b.sortOrder<0)&&t.push(`Unit "${b.key}" has invalid sortOrder "${b.sortOrder}" (must be a non-negative number).`)}let I=/^[0-9a-f]{32}:[0-9a-f]{128}$/;for(let b of e.foundation.users){p.has(b.permissionGroupKey)||t.push(`User "${b.email}" references missing permission group "${b.permissionGroupKey}".`),b.unitKey&&!u.has(b.unitKey)&&t.push(`User "${b.email}" references missing unit "${b.unitKey}".`),b.status!==void 0&&b.status!=="deactivated"&&t.push(`User "${b.email}": status must be "deactivated" or absent, not "${String(b.status)}".`);let R=[b,...b.additionalMemberships??[]];for(let P of b.additionalMemberships??[])p.has(P.permissionGroupKey)||t.push(`User "${b.email}" references missing permission group "${P.permissionGroupKey}".`),P.unitKey&&!u.has(P.unitKey)&&t.push(`User "${b.email}" references missing unit "${P.unitKey}".`);Tn(R.map(P=>`${P.permissionGroupKey}/${P.unitKey??""}`),`membership (permission group/unit) of user "${b.email}"`,t);for(let P of R)P.validFrom!==void 0&&P.validTo!==void 0&&P.validTo<=P.validFrom&&t.push(`User "${b.email}": membership "${P.permissionGroupKey}" ends (validTo) before it starts (validFrom).`);let q=[b.firstName,b.lastName];q.some(P=>P!==void 0)&&q.some(P=>typeof P!="string"||P.trim()==="")&&t.push(`[config/userNameIncomplete] User "${b.email}" states only part of firstName/lastName (or an empty one) \u2014 set both or neither.`);for(let P of["staging","prod"]){let J=b.passwordHashes?.[P];J!==void 0&&!I.test(J)&&t.push(`User "${b.email}" passwordHashes.${P} is not in Better Auth scrypt format "<32hex>:<128hex>".`)}}ED(e.tenant.branding,t),TD(e.tenant,t);let _=ID(e.fields.flatMap(b=>b.sourceColumns));for(let b of _)r.push(`Source column "${b}" is mapped by more than one field.`);N6(e,t);let T=n.sourceColumns===void 0||e.source===void 0?void 0:O6(e,n.sourceColumns,t);return{ok:t.length===0,errors:t,warnings:r,coverage:T}}s($D,"validateTenantConfig");function v6(e,n){let t=new Map;for(let r of e.objectSchema?.properties??[]){let i=r.addressPart;if(i===void 0)continue;let o=`Object property "${e.key}.${r.key}"`;if(!Cy.includes(i)){n.push(`${o}: addressPart "${i}" is none of ${Cy.join(", ")}.`);continue}e.type!=="object"&&n.push(`${o}: only an object field stores an address (addressPart).`),r.type!=="string"&&n.push(`${o}: addressPart "${i}" needs a string property, not "${r.type}".`);let a=t.get(i);a!==void 0&&n.push(`${o}: addressPart "${i}" is already declared by "${e.key}.${a}".`),t.set(i,r.key)}}s(v6,"validateAddressParts");function x6(e,n){let t=e.relationshipKinds;if(t===void 0)return;if(e.type!=="relationship"){n.push(`Field "${e.key}" declares relationshipKinds, but only a relationship field carries them.`);return}let r=new Map((e.objectSchema?.properties??[]).map(i=>[i.key,i]));for(let i of t){let o=`Field "${e.key}" relationship kind "${i.key}"`;if(typeof i.key!="string"||i.key.trim()===""){n.push(`Field "${e.key}": a relationship kind needs a key.`);continue}for(let l of["de","en"])(i.label?.[l]??"").trim()===""&&n.push(`${o}: label.${l} is required \u2014 [i18n/missingTranslation] every shown text needs German and English.`);if(i.edge===null||typeof i.edge!="object"||Array.isArray(i.edge)){n.push(`${o}: edge must be an object.`);continue}i.sibling!==void 0&&i.sibling!==!0&&n.push(`${o}: sibling must be true or absent.`),i.sibling===!0&&i.mergeInto!==void 0&&n.push(`${o}: a sibling kind's edge is its identity \u2014 it cannot declare mergeInto.`);let a=t.flatMap(l=>l.mergeInto!==void 0?[l.mergeInto]:[]);if(i.sibling===!0&&a.some(l=>l in i.edge)&&n.push(`${o}: a sibling kind's edge is its identity \u2014 it cannot declare a property another kind of the field merges into.`),i.sibling===!0&&Object.keys(i.edge).length===0&&n.push(`${o}: a sibling kind's edge is its identity \u2014 an empty edge would count every edge of the field.`),i.mergeInto!==void 0){let l=r.get(i.mergeInto);l===void 0||l.type!=="0-n-select"?n.push(`${o}: mergeInto "${i.mergeInto}" must name a 0-n-select property of the field's objectSchema.`):Array.isArray(i.edge[i.mergeInto])||n.push(`${o}: mergeInto "${i.mergeInto}" must be set to a list in the edge.`)}}}s(x6,"validateRelationshipKinds");function S6(e,n,t){if(e.autoString===void 0){t.push(`Automatic field "${e.key}" must define autoString.`);return}e.allowMultiple===!0&&t.push(`Automatic field "${e.key}" must not allow multiple values.`),e.shareable===!0&&t.push(`Automatic field "${e.key}" must not be shareable.`),e.autoString.segments.length===0&&t.push(`Automatic field "${e.key}" must define at least one segment.`),e.autoString.segments.filter(i=>i.kind==="sequence").length!==1&&t.push(`Automatic field "${e.key}" must define exactly one sequence segment.`);for(let i of e.autoString.segments)if(i.kind==="literal"&&i.value.length===0&&t.push(`Automatic field "${e.key}" has an empty literal segment.`),i.kind==="sequence"&&(i.startAt!==void 0&&(!Number.isInteger(i.startAt)||i.startAt<1)&&t.push(`Automatic field "${e.key}" sequence startAt must be an integer >= 1.`),i.minDigits!==void 0&&(!Number.isInteger(i.minDigits)||i.minDigits<0)&&t.push(`Automatic field "${e.key}" sequence minDigits must be an integer >= 0.`)),i.kind==="field"){let o=n.get(i.fieldKey);if(o===void 0){t.push(`Automatic field "${e.key}" references missing field "${i.fieldKey}".`);continue}i.objectPropertyKey!==void 0&&o.objectSchema?.properties.find(l=>l.key===i.objectPropertyKey)===void 0&&t.push(`Automatic field "${e.key}" references missing object property "${i.fieldKey}.${i.objectPropertyKey}".`)}}s(S6,"validateAutomaticStringField");function zp(e,n,t,r){if(e===void 0)return;let i=n.get(e.fieldKey);if(i===void 0){t.push(`${r} references missing field "${e.fieldKey}".`);return}if(e.objectPropertyKey===void 0)return;(i.objectSchema?.properties.some(a=>a.key===e.objectPropertyKey)??!1)||t.push(`${r} references missing object property "${e.fieldKey}.${e.objectPropertyKey}".`)}s(zp,"validateSearchTarget");function A6(e,n,t){if(e.source.kind!=="relationshipTargetField")return;let r=`Template placeholder "${e.key}"`,i=n.get(e.source.relationshipFieldKey);if(i===void 0)t.push(`${r} references missing relationship field "${e.source.relationshipFieldKey}".`);else if(i.type!=="relationship")t.push(`${r} relationship field "${e.source.relationshipFieldKey}" must be a relationship field.`);else{for(let a of e.source.edgeFilters??[])$k(i,a.propertyKey,t,`${r} edge filter`);e.source.selection?.sortPropertyKey!==void 0&&$k(i,e.source.selection.sortPropertyKey,t,`${r} selection sort`)}let o=n.get(e.source.targetFieldKey);if(o===void 0){t.push(`${r} references missing target field "${e.source.targetFieldKey}".`);return}o.type==="relationship"&&t.push(`${r} target field "${e.source.targetFieldKey}" must not be a relationship field.`),e.source.targetObjectPropertyKey!==void 0&&$k(o,e.source.targetObjectPropertyKey,t,`${r} target`)}s(A6,"validateRelationshipTemplatePlaceholder");function $k(e,n,t,r){(e.objectSchema?.properties.some(o=>o.key===n)??!1)||t.push(`${r} references missing object property "${e.key}.${n}".`)}s($k,"validateObjectPropertyReference");function E6(e,n,t){let r=`Party result icon "${e.key}"`,i=n.get(e.when.fieldKey);if(i===void 0){t.push(`${r} references missing field "${e.when.fieldKey}".`);return}if(e.when.objectPropertyKey===void 0){i.type!=="boolean"&&t.push(`${r} must target a Boolean field or object property.`);return}let o=i.objectSchema?.properties.find(a=>a.key===e.when.objectPropertyKey);if(o===void 0){t.push(`${r} references missing object property "${e.when.fieldKey}.${e.when.objectPropertyKey}".`);return}o.type!=="boolean"&&t.push(`${r} must target a Boolean field or object property.`)}s(E6,"validatePartyResultIconTarget");function RD(e){return`${e.templateId}:${e.locale}:${e.scopeKey}`}s(RD,"letterIdentity");function T6(e){return`${e.generatorKey??"*"}/${e.partyKind}/${e.roleKey}`}s(T6,"contractRoleMappingIdentity");function $6(e,n,t){let r=new Set;for(let i of e){let o=T6(i),a=`Contract role mapping "${o}"`;hk.includes(i.partyKind)||t.push(`${a}: partyKind must be one of ${hk.join(", ")}.`),n.has(i.roleKey)||t.push(`${a} references missing role "${i.roleKey}".`),i.generatorKey!==void 0&&i.generatorKey.trim()===""&&t.push(`${a}: generatorKey must not be blank \u2014 omit it for the tenant default.`),r.has(o)&&t.push(`${a} is declared twice.`),r.add(o)}}s($6,"validateContractRoleMappings");function R6(e,n){for(let t of e){let r=`Notification letter "${RD(t)}"`;if(!Kp(t.locale)){n.push(`${r} declares locale "${String(t.locale)}" \u2014 letters are written in ${We.map(i=>`"${i}"`).join(" and ")} only, so no mail would ever read this deviation.`);continue}if(t.scopeKey!==Mp){n.push(`${r} declares scopeKey "${t.scopeKey}" \u2014 the only scope is "${Mp}" (the whole school).`);continue}if(Object.keys(t.slots).length===0){n.push(`${r} overrides no block. A deviation that deviates in nothing is not an entry \u2014 remove it.`);continue}if(!aw(t.templateId)){n.push(`${r} references no registered letter \u2014 "${t.templateId}" is not in the letter catalog.`);continue}for(let i of lD(sw(t.templateId),t.slots,t.locale))n.push(`${r}, block "${i.slotKey}" [${i.code}]: ${i.message.de}`)}}s(R6,"validateNotificationLetters");function I6(e,n){if(e!==void 0)for(let t of dD(e))n.push(`Notification chrome: ${t.de}`)}s(I6,"validateNotificationChrome");function ED(e,n,t){if(e===void 0)return;let r=t===void 0?n:{push:s((...p)=>n.push(...p.map(m=>`${t}: ${m}`)),"push")},i=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,o=/^(?:rgb|rgba|hsl|hsla)\(.+\)$/i,a=s(p=>i.test(p.trim())||o.test(p.trim()),"isColor");for(let[p,m]of Object.entries(e.colors??{}))m!==void 0&&(a(m)||r.push(`Branding color "colors.${p}" has invalid value "${m}" (expected hex "#rgb"/"#rrggbb"/"#rrggbbaa" or rgb()/rgba()/hsl()/hsla()).`));let l=["sharp","rounded","soft"];e.radius!==void 0&&!l.includes(e.radius)&&r.push(`Branding radius "${e.radius}" is invalid (expected "sharp", "rounded", or "soft").`);let d=["sm","md","lg","max"];e.logoSize!==void 0&&!d.includes(e.logoSize)&&r.push(`Branding logoSize "${e.logoSize}" is invalid (expected "sm", "md", "lg", or "max").`);let c=["compact","normal","spacious"];e.bannerDensity!==void 0&&!c.includes(e.bannerDensity)&&r.push(`Branding bannerDensity "${e.bannerDensity}" is invalid (expected "compact", "normal", or "spacious").`);let u=["light","dark"];e.logoGround!==void 0&&!u.includes(e.logoGround)&&r.push(`Branding logoGround "${e.logoGround}" is invalid (expected "light" or "dark").`),e.websiteUrl!==void 0&&!e.websiteUrl.startsWith("https://")&&r.push(`Branding websiteUrl must be an https:// URL (got "${e.websiteUrl}").`);for(let p of["heading","body"]){let m=e.fonts?.[p];m!==void 0&&((typeof m.family!="string"||m.family.trim().length===0)&&r.push(`Branding font "fonts.${p}" must define a non-empty family.`),Object.hasOwn(m,"url")&&r.push(`Branding font "fonts.${p}.url" is no longer supported \u2014 the font file is uploaded (plexus-cli branding set-font --slot ${p} --file <woff2>) and config carries the family only.`))}}s(ED,"validateBranding");function TD(e,n,t="tenant"){let r=e.brandingAssets;if(r!==void 0){if(typeof r!="object"||r===null||Array.isArray(r)){n.push(`${t}.brandingAssets must be an object keyed by slot (${Vp.join(", ")}).`);return}for(let[i,o]of Object.entries(r)){let a=`${t}.brandingAssets.${i}`;if(!Vp.includes(i)){n.push(`${a}: unknown slot (expected ${Vp.join(", ")}).`);continue}if(typeof o!="object"||o===null){n.push(`${a}: must be { sha256, sizeBytes, mimeType }.`);continue}if("size"in o){n.push(`[config/fileRefRenamed] ${a} still names size \u2014 this bundle was exported before the file-field rename, or by a plexus-cli older than this release (now sizeBytes). Update plexus-cli, export it again (plexus-cli --env <env> config export) and re-apply.`);continue}OD.test(o.sha256??"")||n.push(`${a}: sha256 must be 64 lowercase hex chars.`),(!Number.isInteger(o.sizeBytes)||o.sizeBytes<=0)&&n.push(`${a}: sizeBytes must be a positive integer.`);let l=fD[i];if(l===null){let d=pD({contentType:o.mimeType,size:o.sizeBytes});d!==null&&n.push(`${a}: ${d.de}`)}else{o.mimeType!==Ek&&n.push(`${a}: mimeType must be "${Ek}" (got "${o.mimeType}").`);let d=mD(e.branding?.fonts?.[l]?.family);d!==null&&n.push(`${a}: [branding/fontFamilyMissing] ${t}.branding.fonts.${l}: ${d.de}`)}"path"in o&&n.push(`${a}: "path" is a CLI snapshot field \u2014 resolve it with plexus-cli config apply.`)}}}s(TD,"validateBrandingAssets");function O6(e,n,t){let{source:r}=e;r===void 0&&F("validateSourceCoverage: called without a `source` block.");let i=new Set(n),o=new Set(e.fields.flatMap(k=>k.sourceColumns)),a=new Set(e.deferredColumns.map(k=>k.column)),l=new Set(e.ignoredColumns.map(k=>k.column)),d=new Set([...o,...a,...l]),c=r.requiredColumns.filter(k=>!i.has(k)),u=n.filter(k=>!d.has(k)),p=[...o].filter(k=>!i.has(k)),m=[...a].filter(k=>!i.has(k)),y=[...l].filter(k=>!i.has(k));for(let k of c)t.push(`Required source column "${k}" is missing from ${r.primaryTable}.`);for(let k of u)t.push(`Source column "${k}" is neither mapped nor explicitly deferred/ignored.`);for(let k of p)t.push(`Mapped source column "${k}" does not exist in the source schema.`);for(let k of m)t.push(`Deferred source column "${k}" does not exist in the source schema.`);for(let k of y)t.push(`Ignored source column "${k}" does not exist in the source schema.`);return{table:r.primaryTable,availableColumns:n.length,mappedColumns:[...o].filter(k=>i.has(k)).length,deferredColumns:[...a].filter(k=>i.has(k)).length,ignoredColumns:[...l].filter(k=>i.has(k)).length,missingRequiredColumns:c,unmappedColumns:u,unknownMappedColumns:p,unknownDeferredColumns:m,unknownIgnoredColumns:y}}s(O6,"validateSourceCoverage");function Tn(e,n,t){for(let r of ID(e))t.push(`Duplicate ${n} key "${r}".`)}s(Tn,"requireUnique");function ID(e){let n=new Set,t=new Set;for(let r of e)n.has(r)&&t.add(r),n.add(r);return[...t]}s(ID,"duplicates");var OD=/^[0-9a-f]{64}$/,P6=["fileName","size"];function N6(e,n){if(!Array.isArray(e.files)){n.push('"files" is missing \u2014 declare the file library (an empty list is fine).');return}Tn(e.files.map(t=>t.key),"file",n);for(let t of e.files){let r=`files["${t.key}"]`;oa(t.key)||n.push(`${r}: key must match ${Gw}.`);for(let o of["de","en"])(t.label?.[o]??"").trim()===""&&n.push(`${r}: label.${o} is required \u2014 [i18n/missingTranslation] every shown text needs German and English.`);let i=P6.filter(o=>o in t);if(i.length>0){n.push(`[config/fileRefRenamed] ${r} still names ${i.join(", ")} \u2014 this bundle was exported before the file-field rename, or by a plexus-cli older than this release (now filename / sizeBytes). Update plexus-cli, export it again (plexus-cli --env <env> config export) and re-apply.`);continue}if(typeof t.filename!="string")n.push(`${r}: filename is missing.`);else{let o=_o(t.filename);o!==null&&n.push(`${r}: filename ${o}.`)}qp.includes(t.mimeType)||n.push(`${r}: mimeType "${t.mimeType}" is not allowed (${qp.join(", ")}).`),OD.test(t.sha256??"")||n.push(`${r}: sha256 must be 64 lowercase hex chars.`),(!Number.isInteger(t.sizeBytes)||t.sizeBytes<=0)&&n.push(`${r}: sizeBytes must be a positive integer.`),"path"in t&&n.push(`${r}: "path" is a CLI snapshot field \u2014 resolve it with plexus-cli config apply.`)}}s(N6,"validateFiles");var _6=new WeakMap,C6=new WeakSet;function Rk(e,n){n(e);let r=e.asOptional.bind(e);return Object.defineProperty(e,"asOptional",{value:s(()=>Rk(r(),n),"value"),enumerable:!1}),e}s(Rk,"carry");function pa(e,n){return Rk(e,t=>_6.set(t,n))}s(pa,"tagged");var D6="tenant teardown drains every table explicitly (config/wipe.ts)",Yn={belongsTo:s(e=>pa(e,{kind:"belongsTo"}),"belongsTo"),owns:s(e=>pa(e,{kind:"owns"}),"owns"),holds:s(e=>pa(e,{kind:"holds"}),"holds"),restrict:s((e,n)=>pa(e,n?{kind:"restrict",unindexed:n.unindexed}:{kind:"restrict"}),"restrict"),history:s(e=>pa(e,{kind:"history"}),"history"),tenant:s(e=>pa(e,{kind:"restrict",unindexed:D6}),"tenant"),historyOf:s(e=>Rk(e,n=>C6.add(n)),"historyOf")};var F6=w.object({street:w.string(),hausnr:w.string(),plz:w.string(),ort:w.string()}),PD=w.union(w.literal("school_operator"),w.literal("school_group"),w.literal("service_entity")),Br=PD.members.map(e=>e.value),L6={tenantId:Yn.tenant(w.id("tenants")),name:w.optional(w.string()),type:PD,parentLegalEntityId:w.optional(Yn.restrict(w.id("legal_entities"))),configKey:w.optional(w.string()),partyId:w.optional(Yn.restrict(w.id("parties"))),address:w.optional(F6),signatoryUserId:w.optional(Yn.restrict(w.id("users"))),terms:w.optional(sD)},nSe=Jr(L6).index("by_tenantId",["tenantId"]).index("by_parentLegalEntityId",["parentLegalEntityId"]).index("by_tenantId_and_configKey",["tenantId","configKey"]).index("by_partyId",["partyId"]).index("by_signatoryUserId",["signatoryUserId"]);var M6=w.union(w.literal("school"),w.literal("kindergarten"),w.literal("after_school_care"),w.literal("department"),w.literal("site"),w.literal("other")),Ft=M6.members.map(e=>e.value),iSe=w.union(w.literal("school"),w.literal("vocational"),w.literal("care"),w.literal("seminar"),w.literal("other")),oSe=w.union(w.literal("none"),w.literal("manual"),w.literal("annual_rollover")),sSe=w.union(w.literal("grade_level"),w.literal("module"),w.literal("phase"),w.literal("other")),aSe=w.union(w.literal("school_year"),w.literal("cohort"),w.literal("seminar"),w.literal("care_period"),w.literal("other")),lSe=w.union(w.literal("planned"),w.literal("active"),w.literal("completed"),w.literal("archived")),dSe=w.union(w.literal("class"),w.literal("course"),w.literal("care_group"),w.literal("seminar_group"),w.literal("mixed_age_group"),w.literal("other")),cSe=w.union(w.literal("planned"),w.literal("active"),w.literal("completed"),w.literal("cancelled")),uSe=w.union(w.literal("class_teacher"),w.literal("teacher"),w.literal("mentor"),w.literal("instructor"),w.literal("assistant"),w.literal("other")),fSe=w.union(w.literal("units"),w.literal("unit_profiles"),w.literal("programs"),w.literal("program_stages"),w.literal("program_runs"),w.literal("learning_groups"),w.literal("enrollments"),w.literal("learning_group_staff_assignments")),pSe=w.union(w.literal("open"),w.literal("mapped"),w.literal("ignored"));function _D(e){let n=["street","hausnr","plz","ort"].filter(t=>e[t]!==void 0);if(n.length!==0){if(n.length!==4)throw new Error(`config legal-entity add: an address needs all of --street, --hausnr, --plz and --ort (got ${n.map(t=>`--${t}`).join(", ")})`);return{street:e.street,hausnr:e.hausnr,plz:e.plz,ort:e.ort}}}s(_D,"addressFrom");function CD(e){if(!Br.includes(e))throw new Error(`config legal-entity add: --type "${e}" is none of ${Br.join(", ")}`);return e}s(CD,"legalEntityType");function DD(e){if(!Ft.includes(e))throw new Error(`config unit add: --kind "${e}" is none of ${Ft.join(", ")}`);return e}s(DD,"unitKind");function FD(e,n,t){let r=e.find(i=>i.key===n.key);if(r===void 0)return e.push(n),"create";if(Pe(r)===Pe(n))return"same";throw new Error(`${t} "${n.key}" already exists with other values \u2014 decide by hand, nothing written.
|
|
11201
|
+
`)).includes(u.key));if(p.length===0)continue;let m=s((g,v)=>g.map(E=>v(i.find(A=>A.key===E)?.label??E)).join(" + "),"variantLabel"),y=c.length===1?"":` Er fehlt in der Fassung aus ${p.map(g=>m(g,v=>`\u201E${v}\u201C`)).join(" und in der aus ")}.`,k=c.length===1?"":` It is missing in the version made of ${p.map(g=>m(g,v=>`"${v}"`)).join(" and in the one made of ")}.`;r.push({slotKey:u.key,code:"missingRequired",message:{de:`Ohne \u201E{{${u.key}}}\u201C (${u.label}) funktioniert der Brief \u201E${e.label}\u201C nicht \u2014 der Platzhalter muss im Text stehen, nicht nur im Betreff.`+y,en:`Without "{{${u.key}}}" (${u.label}) the letter "${e.label}" does not work \u2014 the placeholder must be in the text, not only in the subject.`+k}})}return r}s(lD,"validateOverride");function KJ(e,n,t){let r=e.find(i=>i.key===n);return r===void 0?"":qJ(r,t)}s(KJ,"defaultTextOf");function Sk(e){let n=e?.trim();return n===void 0||n.length===0?void 0:n}s(Sk,"normalizeChromeText");var Lo=s(e=>String.fromCharCode(e),"cp"),jJ=new RegExp(`[${Lo(0)}-${Lo(31)}${Lo(127)}]`,"g"),BJ=new RegExp(`[${Lo(8234)}-${Lo(8238)}${Lo(8294)}-${Lo(8297)}]`,"g");var VJ=200;function UJ(e,n=VJ){return e.replace(jJ," ").replace(BJ,"").replace(/\s+/g," ").trim().slice(0,n)}s(UJ,"sanitizeHeaderValue");function Bp(e){return UJ(e.replace(/["<>@]/g,""),100)}s(Bp,"sanitizeDisplayName");var Ak={de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}},GJ={greeting:{de:"Anrede",en:"Greeting"},closing:{de:"Gru\xDFformel",en:"Closing"}};function dD(e){let n=[],t=[];for(let i of["greeting","closing"]){let o=e[i];if(o===void 0)continue;let a=GJ[i],l=Rn(o);l!=="not-localized"&&l.length>0&&l.length<We.length&&t.push({de:`${a.de} fehlt auf ${l.map(d=>Ak[d].de).join(" und ")}`,en:`${a.en} is missing in ${l.map(d=>Ak[d].en).join(" and ")}`});for(let d of We){let c=Jy(m=>`${a[m]} (${Ak[d][m]})`),u=Sk(o[d]);u!==void 0&&u.length>Fo&&n.push({de:`${c.de} hat ${u.length} Zeichen \u2014 h\xF6chstens ${Fo}; der Briefrahmen ist eine Zeile der Mail, kein Dokument.`,en:`${c.en} has ${u.length} characters \u2014 at most ${Fo}; the letter frame is one line of the mail, not a document.`});let p=i==="greeting"?[jr]:[];for(let m of jp(u??""))p.includes(m)||n.push(p.length===0?{de:`${c.de} kann keine Platzhalter tragen \u2014 \u201E{{${m}}}\u201C bliebe unersetzt stehen.`,en:`${c.en} cannot carry placeholders \u2014 "{{${m}}}" would stay in the text unreplaced.`}:{de:`\u201E{{${m}}}\u201C gibt es in der ${c.de} nicht. Erlaubt: {{${jr}}} (${fa}).`,en:`"{{${m}}}" does not exist in the ${c.en}. Allowed: {{${jr}}} (${fa}).`})}}t.length>0&&n.unshift({de:`[notification/chromeMissingTranslation] ${t.map(i=>i.de).join("; ")} \u2014 der Briefrahmen gilt f\xFCr jeden Brief, in jeder Sprache.`,en:`[notification/chromeMissingTranslation] ${t.map(i=>i.en).join("; ")} \u2014 the letter frame applies to every letter, in every language.`});let r=Sk(e.senderName);return r!==void 0&&Bp(r)!==r&&n.push({de:`Absendername (senderName) \u201E${r}\u201C \xFCbersteht die Kopfzeile der Mail nicht unver\xE4ndert \u2014 er ginge als \u201E${Bp(r)}\u201C hinaus. Keine Anf\xFChrungszeichen, spitzen Klammern, \u201E@\u201C oder Steuerzeichen.`,en:`The sender name (senderName) "${r}" does not survive the mail header unchanged \u2014 it would go out as "${Bp(r)}". No quotation marks, angle brackets, "@" or control characters.`}),n}s(dD,"chromeFindings");var cD=w.object({family:w.string()}),uD=w.object({family:w.string(),url:w.optional(w.string())}),qve=w.object({heading:w.optional(uD),body:w.optional(uD)}),zJ=w.union(w.literal("sharp"),w.literal("rounded"),w.literal("soft")),WJ=w.union(w.literal("light"),w.literal("dark")),YJ=w.union(w.literal("sm"),w.literal("md"),w.literal("lg"),w.literal("max")),HJ=w.union(w.literal("compact"),w.literal("normal"),w.literal("spacious")),JJ=w.object({primary:w.optional(w.string()),accent:w.optional(w.string()),background:w.optional(w.string()),foreground:w.optional(w.string())}),QJ=w.object({heading:w.optional(cD),body:w.optional(cD)}),Kve=w.object({colors:w.optional(JJ),radius:w.optional(zJ),logoSize:w.optional(YJ),bannerDensity:w.optional(HJ),logoGround:w.optional(WJ),filledHeader:w.optional(w.boolean()),websiteUrl:w.optional(w.string()),fonts:w.optional(QJ)}),jve=w.object({primaryUrl:w.union(w.null(),w.string())}),Bve=w.literal("primary"),Vve=w.object({headingUrl:w.union(w.null(),w.string()),bodyUrl:w.union(w.null(),w.string())}),Uve=w.union(w.literal("heading"),w.literal("body")),Vp=["logo","fontHeading","fontBody"],fD={logo:null,fontHeading:"heading",fontBody:"body"};function pD(e){let{contentType:n,size:t}=e;return n==null||!n.startsWith("image/")?{de:`Das Logo muss ein Bild sein (erhalten: \u201E${n??"unbekannt"}\u201C).`,en:`The logo must be an image (received: "${n??"unknown"}").`}:n.startsWith("image/svg")?{de:"Das Logo muss eine Rastergrafik sein (PNG, JPEG oder GIF) \u2013 E-Mail-Programme zeigen SVG nicht an.",en:"The logo must be a raster image (PNG, JPEG or GIF) \u2013 email clients do not display SVG."}:t>3e6?{de:`Das Logo ist zu gro\xDF (${t} Byte, h\xF6chstens 3000000 Byte).`,en:`The logo is too large (${t} bytes, at most 3000000 bytes).`}:null}s(pD,"logoFileProblem");var Ek="font/woff2";var ZJ=["Inter Variable","Azeret Mono Variable","Source Sans 3 Variable"];function mD(e){return e?.trim()?ZJ.some(n=>n.toLowerCase()===e.trim().toLowerCase())?{de:`\u201E${e}\u201C ist die Schrift von Plexus selbst \u2013 w\xE4hlen Sie f\xFCr eine eigene Datei einen anderen Familiennamen.`,en:`"${e}" is Plexus's own typeface \u2013 choose a different family name for your own file.`}:null:{de:"Speichern Sie zuerst die Schriftfamilie \u2013 die Datei wird unter diesem Namen eingebunden.",en:"Save the font family first \u2013 the file is registered under that name."}}s(mD,"fontFamilyProblem");var XJ=["approved","rejected","withdrawn","waitlist","expired"];var Up=["admitted","rejected","withdrawn","waitlist","expired","unknown"],Qve=w.union(...XJ.map(e=>w.literal(e))),Zve=w.union(...Up.map(e=>w.literal(e))),e4=["approved","rejected","waitlist"],n4=["withdrawn","expired"],t4=w.union(...e4.map(e=>w.literal(e))),r4=w.union(...n4.map(e=>w.literal(e))),Xve={active:{status:w.literal("active")},completed:{status:w.literal("completed"),outcome:t4,endedAt:w.number()},aborted:{status:w.literal("aborted"),outcome:w.optional(r4),endedAt:w.number()}};var hD=30,gD=3650;var i4=w.object({admitted:w.optional(w.number()),rejected:w.optional(w.number()),withdrawn:w.optional(w.number()),expired:w.optional(w.number()),waitlist:w.optional(w.number()),unknown:w.optional(w.number())}),oxe=i4.fields,o4=s(e=>Up.includes(e),"isClassification");function yD(e,n="tenant.retentionDays"){if(e===null||typeof e!="object"||Array.isArray(e))return[`[retention/shape] ${n} must be an object of days per classification (got ${JSON.stringify(e)}).`];let t=[];for(let[r,i]of Object.entries(e)){if(!o4(r)){t.push(`[retention/unknownClassification] ${n}.${r} is no retention classification \u2014 one of ${Up.join(", ")}.`);continue}(typeof i!="number"||!Number.isSafeInteger(i)||i<hD||i>gD)&&t.push(`[retention/days] ${n}.${r} must be a whole number of days from ${hD} to ${gD} (got ${JSON.stringify(i)}).`)}return t}s(yD,"retentionDaysFindings");var s4=["ad","ae","af","ag","ai","al","am","ao","aq","ar","as","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bl","bm","bn","bo","bq","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","cr","cu","cv","cw","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","eh","er","es","et","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mf","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","ss","st","sv","sx","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tr","tt","tv","tw","tz","ua","ug","um","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","xk","ye","yt","za","zm","zw"],a4=new Set(s4);function Gp(e){return a4.has(e)}s(Gp,"isCountryCode");var Tk=["off","always","deviating"],wD={mode:"deviating",defaultCountryCode:"de"};var l4=["street","plz","ort"];function d4(e){return l4.filter(n=>!e.has(n))}s(d4,"missingInvoiceAddressParts");var c4=new Set(["0-1-select","0-n-select"]);function kD(e){return e===void 0?null:new Set(e.properties.flatMap(n=>n.addressPart!==void 0&&SO(n.addressPart)?[n.addressPart]:[]))}s(kD,"declaredAddressParts");function u4(e){return c4.has(e)}s(u4,"isSelectFieldKind");function bD(e){let n=[];for(let o of e)if(o.isNationality&&(u4(o.kind)?o.listKind!=="country"&&n.push({code:"nationality/notCountryList",fieldKey:o.key}):n.push({code:"nationality/wrongFieldKind",fieldKey:o.key})),o.isAccountEmail&&o.kind!=="email"&&n.push({code:"accountEmail/wrongFieldKind",fieldKey:o.key}),o.isContactPhone&&o.kind!=="tel"&&n.push({code:"contactPhone/wrongFieldKind",fieldKey:o.key}),o.isInvoiceAddress)if(o.addressParts===null)n.push({code:"invoiceAddress/wrongFieldKind",fieldKey:o.key});else{let a=d4(o.addressParts);a.length>0&&n.push({code:"invoiceAddress/missingPart",fieldKey:o.key,parts:a})}let t=e.filter(o=>o.isAccountEmail);if(t.length>1)for(let o of t)n.push({code:"accountEmail/multiple",fieldKey:o.key});let r=e.filter(o=>o.isContactPhone);if(r.length>1)for(let o of r)n.push({code:"contactPhone/multiple",fieldKey:o.key});let i=e.filter(o=>o.isInvoiceAddress);if(i.length>1)for(let o of i)n.push({code:"invoiceAddress/multiple",fieldKey:o.key});return n}s(bD,"fieldRoleFindings");function vD(e,n,...t){let r=e[n.code];return r(n,...t)}s(vD,"wordListElementFinding");function xD(e,n){let t=[];for(let r of n){if(e.kind==="plain"){r.countryCode!==void 0&&t.push({code:"list/countryCodeOnPlain",elementKey:r.key,countryCode:r.countryCode});continue}r.countryCode===void 0?t.push({code:"list/countryCodeMissing",elementKey:r.key}):r.countryCode!==null&&!Gp(r.countryCode)&&t.push({code:"list/unknownCountryCode",elementKey:r.key,countryCode:r.countryCode})}return t}s(xD,"listElementCountryFindings");var p4={key:!0,tenant:!0,foundation:!0,source:!0,displayGroups:!0,lists:!0,roles:!0,fields:!0,roleFields:!0,contractRoleMappings:!0,templatePlaceholders:!0,searchTargets:!0,searchFilters:!0,partyResultIcons:!0,notificationLetters:!0,admission:!0,files:!0,agent:!0,deferredColumns:!0,ignoredColumns:!0},m4={slug:!0,name:!0,enabledModules:!0,permissions:!0,defaultApplicantGroupKey:!0,defaultEnrolleeRoleKey:!0,priceCriteriaFacts:!0,defaultInteressentRoleKey:!0,admissionFieldDisplayGroupKey:!0,defaultStartInProxy:!0,terms:!0,retentionDays:!0,mailLevel:!0,notificationChrome:!0,hideMailLevelNotice:!0,magicLinkLogin:!0,externalSignIn:!0,nationalityFlag:!0,adminSeesSignatureImages:!0,signatureStamp:!0,bankImportScope:!0,branding:!0,brandingAssets:!0,partyRetention:!0},h4=new Set(["enabledMailCategories","mailEnabled"]);function g4(e){let n=s((t,r,i)=>t.filter(o=>!Object.hasOwn(r,o)&&!(i==="tenant."&&h4.has(o))).map(o=>`[config/unknownKey] ${i}${o} is not a config field of this release \u2014 a typo, or a field a newer release introduced.`),"unknown");return[...n(Object.keys(e),p4,""),...n(Object.keys(e.tenant),m4,"tenant.")]}s(g4,"unknownKeyFindings");var SD=["plain","country"],y4={"list/countryCodeMissing":s(({elementKey:e},n)=>`Element "${n}.${e}" of a country list must state countryCode (null for no state).`,"list/countryCodeMissing"),"list/countryCodeOnPlain":s(({elementKey:e},n)=>`Element "${n}.${e}" carries countryCode, but list "${n}" is not kind "country".`,"list/countryCodeOnPlain"),"list/unknownCountryCode":s(({elementKey:e,countryCode:n},t)=>`Element "${t}.${e}" has unknown countryCode ${JSON.stringify(n)}.`,"list/unknownCountryCode")},w4={"nationality/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isNationality but not a 0-1-select / 0-n-select.`,"nationality/wrongFieldKind"),"nationality/notCountryList":s(({fieldKey:e})=>`Field "${e}" is isNationality but its list is not kind "country".`,"nationality/notCountryList"),"accountEmail/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isAccountEmail but not an email field.`,"accountEmail/wrongFieldKind"),"accountEmail/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isAccountEmail fields \u2014 at most one per tenant.`,"accountEmail/multiple"),"contactPhone/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isContactPhone but not a tel field.`,"contactPhone/wrongFieldKind"),"contactPhone/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isContactPhone fields \u2014 at most one per tenant.`,"contactPhone/multiple"),"invoiceAddress/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isInvoiceAddress but not an object field.`,"invoiceAddress/wrongFieldKind"),"invoiceAddress/missingPart":s(({fieldKey:e,parts:n})=>`Field "${e}" is isInvoiceAddress but declares no property for the address part(s) ${n.join(", ")} (objectSchema.properties[].addressPart) \u2014 an invoice cannot print its address without them.`,"invoiceAddress/missingPart"),"invoiceAddress/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isInvoiceAddress fields \u2014 at most one per tenant.`,"invoiceAddress/multiple")};function k4(e){let n=w4[e.code];return n(e)}s(k4,"roleText");function b4(e){let n=[],t=e.tenant.nationalityFlag,r=typeof t=="object"&&t!==null?t:{},i=r.mode;if(Tk.includes(i)||n.push(`[nationality/flagMode] tenant.nationalityFlag.mode must be one of ${Tk.join(", ")} (got ${t===void 0?"no tenant.nationalityFlag":JSON.stringify(i??null)}).`),t!==void 0){let l=r.defaultCountryCode;(typeof l!="string"||!Gp(l))&&n.push(`[nationality/defaultCountryCode] tenant.nationalityFlag.defaultCountryCode must be a lowercase ISO 3166-1 alpha-2 code (got ${JSON.stringify(l??null)}).`)}let o=new Map;for(let l of e.lists){let d=l.kind;if(!SD.includes(d)){n.push(`[list/kind] List "${l.key}" has kind ${JSON.stringify(d??null)} \u2014 one of ${SD.join(", ")}.`);continue}o.set(l.key,l.kind);for(let c of xD({key:l.key,kind:l.kind},l.elements))n.push(`[${c.code}] ${vD(y4,c,l.key)}`)}let a=bD(e.fields.map(l=>({key:l.key,kind:l.type,listKind:l.listKey===void 0?null:o.get(l.listKey)??null,isNationality:l.isNationality===!0,isAccountEmail:l.isAccountEmail===!0,isContactPhone:l.isContactPhone===!0,isInvoiceAddress:l.isInvoiceAddress===!0,addressParts:l.type==="object"?kD(l.objectSchema??{properties:[]}):null})));for(let l of a)n.push(`[${l.code}] ${k4(l)}`);return n}s(b4,"nationalityFindings");function AD(e){return vi(e)?.message.de??(e instanceof Error?e.message:String(e))}s(AD,"errorText");function $D(e,n={}){let t=[...g4(e)],r=[];try{JC(e.fields.map(b=>b.key),[])}catch(b){t.push(AD(b))}e.tenant.terms!==void 0&&t.push(...xk(e.tenant.terms)),e.tenant.retentionDays!==void 0&&t.push(...yD(e.tenant.retentionDays)),mP(e.tenant.mailLevel)?e.tenant.mailLevel==="all"&&!Lp(e.tenant.enabledModules,"notifications")&&t.push('[notification/levelWithoutModule] tenant.mailLevel is "all" but the notifications module is not enabled \u2014 only sign-in and security mail would go out. Enable the module or set "loginOnly".'):t.push(`[notification/mailLevel] tenant.mailLevel must be one of ${ew.join(", ")} (got ${e.tenant.mailLevel===void 0?"nothing":JSON.stringify(e.tenant.mailLevel)}).`),"enabledMailCategories"in e.tenant&&t.push('[notification/mailCategoriesRetired] tenant.enabledMailCategories was replaced by tenant.mailLevel \u2014 "all" for every mail, "loginOnly" for sign-in mail only to families (staff mail follows personal settings).'),"mailEnabled"in e.tenant&&t.push('[notification/mailEnabledRetired] tenant.mailEnabled was replaced by tenant.mailLevel \u2014 "all" for every mail, "loginOnly" for sign-in mail only to families (staff mail follows personal settings).'),Tn(e.displayGroups.map(b=>b.key),"display group",t),Tn(e.lists.map(b=>b.key),"list",t),Tn(e.roles.map(b=>b.key),"role",t),Tn(e.fields.map(b=>b.key),"field",t),Tn(e.foundation.legalEntities.map(b=>b.key),"legal entity",t),Tn(e.foundation.units.map(b=>b.key),"unit",t),Tn(e.foundation.permissionGroups.map(b=>b.key),"permission group",t),"teams"in e.foundation&&t.push("foundation.teams is retired: a team is a permission group \u2014 move each team to foundation.permissionGroups (same key) and remove the block.");for(let b of e.foundation.users)"teamKeys"in b&&t.push(`User "${b.email}" carries teamKeys, retired: team membership is the user's permission-group membership.`);Tn(e.foundation.users.map(b=>b.key),"user",t),Tn((e.searchFilters??[]).map(b=>b.key),"search filter",t),Tn((e.searchTargets??[]).map(b=>b.objectPropertyKey===void 0?b.fieldKey:`${b.fieldKey}.${b.objectPropertyKey}`),"search target",t),Tn((e.partyResultIcons??[]).map(b=>b.key),"party result icon",t),Tn((e.templatePlaceholders??[]).map(b=>b.key),"template placeholder",t),Tn((e.notificationLetters??[]).map(RD),"notification letter",t),R4(e.notificationLetters??[],t),I4(e.tenant.notificationChrome,t),e.tenant.bankImportScope!==void 0&&!["sepa_only","full_statement"].includes(e.tenant.bankImportScope)&&t.push("tenant.bankImportScope must be sepa_only or full_statement."),e.tenant.hideMailLevelNotice!==void 0&&typeof e.tenant.hideMailLevelNotice!="boolean"&&t.push("tenant.hideMailLevelNotice must be true or false (the dashboard's mail-level notice)."),typeof e.tenant.magicLinkLogin!="boolean"&&t.push("tenant.magicLinkLogin must be true or false (the login page's sign-in link option)."),typeof e.tenant.adminSeesSignatureImages!="boolean"&&t.push("tenant.adminSeesSignatureImages must be true or false (whether a school administrator sees other accounts' signature images)."),typeof e.tenant.signatureStamp!="boolean"&&t.push("tenant.signatureStamp must be true or false (whether the school offers the signature stamp at the countersignature)."),WC(e.tenant.externalSignIn)?t.push(`[auth/externalSignInRetired] tenant.externalSignIn names the retired mode "${String(e.tenant.externalSignIn.mode)}" \u2014 every sign-in link now signs in once; state { mode: "oneTimeLink" }.`):zC(e.tenant.externalSignIn)||t.push('[auth/externalSignIn] tenant.externalSignIn must be { mode: "oneTimeLink" } (how families sign in).');let i=new Set(e.displayGroups.map(b=>b.key)),o=new Set(e.lists.map(b=>b.key)),a=new Set(e.roles.map(b=>b.key)),l=new Set(e.fields.map(b=>b.key)),d=new Map(e.fields.map(b=>[b.key,b])),c=new Set(e.foundation.legalEntities.map(b=>b.key)),u=new Set(e.foundation.units.map(b=>b.key)),p=new Set(e.foundation.permissionGroups.map(b=>b.key));Lp(e.tenant.enabledModules,"bewerbungsmanagement")&&e.tenant.defaultApplicantGroupKey!==void 0&&(e.foundation.permissionGroups.find(R=>R.key===e.tenant.defaultApplicantGroupKey)?.permissions.includes("bewerbungsmanagement.applications.submitOwn")||t.push(`Default applicant group "${e.tenant.defaultApplicantGroupKey}" must grant submitOwn.`));let m=e.tenant.admissionFieldDisplayGroupKey;m!==void 0&&!i.has(m)&&t.push(`tenant.admissionFieldDisplayGroupKey "${m}" names no display group of this config.`),m===void 0&&(Lp(e.tenant.enabledModules,"bewerbungsmanagement")||(e.admission?.fields.length??0)>0)&&t.push("tenant.admissionFieldDisplayGroupKey is required when admissions is enabled or admission.fields declares fields: it names the display group the fields an offer creates land in."),t.push(...b4(e)),Tn(e.fields.flatMap(b=>(b.relationshipKinds??[]).map(R=>R.key)),"relationship kind",t);for(let b of e.fields){i.has(b.displayGroupKey)||t.push(`Field "${b.key}" references missing display group "${b.displayGroupKey}".`),x4(b,t),b.formWritable===!0&&!kk[b.type].fieldMapTarget&&t.push(`Field "${b.key}" is formWritable, but a form cannot write a "${b.type}" field.`),b.type==="files"&&b.shareable===!0&&t.push(`[field/filesShareable] Field "${b.key}" is a files field and cannot be shareable.`),b.type==="auto-string"?S4(b,d,t):b.autoString!==void 0&&t.push(`Non-automatic field "${b.key}" must not define autoString.`),(!Number.isFinite(b.sortOrder)||b.sortOrder<0)&&t.push(`Field "${b.key}" has invalid sortOrder "${b.sortOrder}" (must be a non-negative number).`),(b.type==="0-1-select"||b.type==="0-n-select")&&!b.listKey&&t.push(`Select field "${b.key}" must define listKey.`),b.type!=="0-1-select"&&b.type!=="0-n-select"&&b.listKey!==void 0&&t.push(`Non-select field "${b.key}" must not define listKey.`),b.listKey&&!o.has(b.listKey)&&t.push(`Field "${b.key}" references missing list "${b.listKey}".`),(b.type==="object"||b.type==="relationship")&&!b.objectSchema&&t.push(`Field "${b.key}" must define objectSchema.`),b.type!=="object"&&b.type!=="relationship"&&b.objectSchema&&t.push(`Non-object field "${b.key}" must not define objectSchema.`);for(let R of b.objectSchema?.properties??[])(R.type==="0-1-select"||R.type==="0-n-select")&&!R.listKey&&t.push(`Object select property "${b.key}.${R.key}" must define listKey.`),R.listKey&&!o.has(R.listKey)&&t.push(`Object property "${b.key}.${R.key}" references missing list "${R.listKey}".`);v4(b,t)}let y=e.tenant.priceCriteriaFacts;if(y){let b=e.fields.find(R=>R.key===y.birthDateFieldKey);(!b||b.type!=="date")&&t.push("Price criteria require a configured date field for birth dates."),a.has(y.studentRoleKey)||t.push("Price criteria require a configured Student eligibility role."),y.siblingRankSource!==void 0&&y.siblingRankSource!=="derived"&&y.siblingRankSource!=="chosen"&&t.push('Price criteria siblingRankSource must be "derived" or "chosen".');for(let R of Object.keys(y))R!=="birthDateFieldKey"&&R!=="studentRoleKey"&&R!=="siblingRankSource"&&t.push(`Unknown price criteria fact setting "${R}".`)}let k=e.tenant.defaultEnrolleeRoleKey;k&&!a.has(k)&&t.push(`Default enrollment role "${k}" does not exist.`),k&&e.roles.some(b=>b.parentRoleKey===k)&&t.push(`Default enrollment role "${k}" must be a leaf role.`);for(let b of e.roles){(typeof b.icon!="string"||b.icon.trim().length===0)&&t.push(`Role "${b.key}" must define an icon.`),b.parentRoleKey&&!a.has(b.parentRoleKey)&&t.push(`Role "${b.key}" references missing parent role "${b.parentRoleKey}".`);for(let R of b.listDisplayFieldKeys??[])l.has(R)||t.push(`Role "${b.key}" list display references missing field "${R}".`)}let g=new Map(e.roles.map(b=>[b.key,b.parentRoleKey])),v=new Map;for(let b of e.roleFields){let R=v.get(b.roleKey)??[];R.push({roleId:b.roleKey,customFieldId:b.fieldKey}),v.set(b.roleKey,R)}for(let b of e.roles)try{YC(b.key,g,v)}catch(R){t.push(AD(R))}for(let b of e.roleFields){a.has(b.roleKey)||t.push(`Role field references missing role "${b.roleKey}" for field "${b.fieldKey}".`),l.has(b.fieldKey)||t.push(`Role field references missing field "${b.fieldKey}" for role "${b.roleKey}".`);for(let R of b.targetRequirementFieldKeys??[])l.has(R)||t.push(`Role field "${b.roleKey}.${b.fieldKey}" references missing target requirement field "${R}".`)}$4(e.contractRoleMappings??[],a,t);for(let b of e.templatePlaceholders??[])AC.test(b.key)||t.push(`Template placeholder "${b.key}" must use lower_snake_case segments, optionally separated by dots.`),b.source.kind==="customField"?zp(b.source,d,t,`Template placeholder "${b.key}"`):b.source.kind==="relationshipTargetField"&&A4(b,d,t);for(let b of e.searchTargets??[])zp(b,d,t,"Search target");for(let b of e.fields)nD(b.key)&&(b.defaultValue!==void 0||b.validations!==void 0)&&t.push(`System field "${b.key}" takes no defaultValue or validations.`);for(let b of e.lists)Tn(b.elements.map((R,q)=>String(R.sortOrder??(q+1)*10)),`sortOrder of an element of list "${b.key}"`,t);for(let b of e.searchFilters??[])Tn((b.options??[]).map((R,q)=>String(R.sortOrder??(q+1)*10)),`sortOrder of an option of search filter "${b.key}"`,t);for(let b of e.foundation.permissionGroups){b.grantAllCustomFields===!0&&b.customFieldPermissions!==void 0&&t.push(`Permission group "${b.key}" states both grantAllCustomFields and customFieldPermissions \u2014 one of them.`),Tn((b.customFieldPermissions??[]).map(R=>R.displayGroupKey),`display group of a field permission of group "${b.key}"`,t);for(let R of b.customFieldPermissions??[]){i.has(R.displayGroupKey)||t.push(`Permission group "${b.key}" grants field permissions on missing display group "${R.displayGroupKey}".`);for(let q of R.permissions)ZC.includes(q)||t.push(`Permission group "${b.key}" grants unknown field permission "${q}".`)}}let E=e.tenant.partyRetention;E!==void 0&&(eD(E.days)||t.push(`tenant.partyRetention.days must be a whole number of days from 1 to ${36500} (got ${JSON.stringify(E.days)}).`),Number.isFinite(E.enabledAt)||t.push("tenant.partyRetention.enabledAt must be a timestamp (epoch ms)."),E.formerRoleKey!==void 0&&!a.has(E.formerRoleKey)&&t.push(`tenant.partyRetention references missing role "${E.formerRoleKey}".`));for(let b of e.searchFilters??[]){(b.kind==="chips"||b.kind==="select")&&(b.options?.length??0)===0&&t.push(`Search filter "${b.key}" must define options.`),(b.kind==="text"||b.kind==="numberRange")&&b.target===void 0&&t.push(`Search filter "${b.key}" must define a target field.`),b.options!==void 0&&Tn(b.options.map(R=>R.key),`search filter option for "${b.key}"`,t),zp(b.target,d,t,`Search filter "${b.key}"`);for(let R of b.options??[]){R.predicates.length===0&&t.push(`Search filter option "${b.key}.${R.key}" must define at least one predicate.`);for(let q of R.predicates){if(q.kind==="role"){a.has(q.roleKey)||t.push(`Search filter option "${b.key}.${R.key}" references missing role "${q.roleKey}".`);continue}zp(q,d,t,`Search filter option "${b.key}.${R.key}"`)}}}for(let b of e.partyResultIcons??[])E4(b,d,t);for(let b of e.foundation.legalEntities)if(b.terms!==void 0&&t.push(...xk(b.terms,`foundation.legalEntities.${b.key}.terms`)),ED(b.branding,t,`foundation.legalEntities.${b.key}.branding`),TD(b,t,`foundation.legalEntities.${b.key}`),b.signatoryUserKey!==void 0&&b.type==="school_group"&&t.push(`[config/signatoryOnGroup] Legal entity "${b.key}" is a school_group \u2014 only a Tr\xE4ger (school_operator, service_entity) declares an Unterschriftsperson.`),b.parentLegalEntityKey&&!c.has(b.parentLegalEntityKey)&&t.push(`Legal entity "${b.key}" references missing parent "${b.parentLegalEntityKey}".`),b.address!==void 0){let R=b.address,q=["street","hausnr","plz","ort"];b.type==="school_group"?t.push(`Legal entity "${b.key}" is a school_group \u2014 only a Tr\xE4ger (school_operator, service_entity) has an address.`):(typeof R!="object"||R===null||Array.isArray(R)||Object.keys(R).some(P=>!q.includes(P))||q.some(P=>typeof R[P]!="string"||(R[P]??"").trim()===""))&&t.push(`Legal entity "${b.key}" has an invalid address \u2014 expected { street, hausnr, plz, ort }, each non-empty.`)}let A=new Map;for(let b of e.foundation.units){if(b.slug!==void 0){let R=typeof b.slug=="string"?FC(b.slug):"must be a string";R!==void 0&&t.push(`Unit "${b.key}" has invalid slug "${b.slug}" (${R}).`);let q=A.get(b.slug);q!==void 0&&t.push(`Units "${q}" and "${b.key}" both declare slug "${b.slug}" (unit slugs are unique per tenant).`),A.set(b.slug,b.key)}c.has(b.legalEntityKey)||t.push(`Unit "${b.key}" references missing legal entity "${b.legalEntityKey}".`),b.parentUnitKey&&!u.has(b.parentUnitKey)&&t.push(`Unit "${b.key}" references missing parent unit "${b.parentUnitKey}".`),b.sortOrder!==void 0&&(!Number.isFinite(b.sortOrder)||b.sortOrder<0)&&t.push(`Unit "${b.key}" has invalid sortOrder "${b.sortOrder}" (must be a non-negative number).`)}let I=/^[0-9a-f]{32}:[0-9a-f]{128}$/;for(let b of e.foundation.users){p.has(b.permissionGroupKey)||t.push(`User "${b.email}" references missing permission group "${b.permissionGroupKey}".`),b.unitKey&&!u.has(b.unitKey)&&t.push(`User "${b.email}" references missing unit "${b.unitKey}".`),b.status!==void 0&&b.status!=="deactivated"&&t.push(`User "${b.email}": status must be "deactivated" or absent, not "${String(b.status)}".`);let R=[b,...b.additionalMemberships??[]];for(let P of b.additionalMemberships??[])p.has(P.permissionGroupKey)||t.push(`User "${b.email}" references missing permission group "${P.permissionGroupKey}".`),P.unitKey&&!u.has(P.unitKey)&&t.push(`User "${b.email}" references missing unit "${P.unitKey}".`);Tn(R.map(P=>`${P.permissionGroupKey}/${P.unitKey??""}`),`membership (permission group/unit) of user "${b.email}"`,t);for(let P of R)P.validFrom!==void 0&&P.validTo!==void 0&&P.validTo<=P.validFrom&&t.push(`User "${b.email}": membership "${P.permissionGroupKey}" ends (validTo) before it starts (validFrom).`);let q=[b.firstName,b.lastName];q.some(P=>P!==void 0)&&q.some(P=>typeof P!="string"||P.trim()==="")&&t.push(`[config/userNameIncomplete] User "${b.email}" states only part of firstName/lastName (or an empty one) \u2014 set both or neither.`);for(let P of["staging","prod"]){let J=b.passwordHashes?.[P];J!==void 0&&!I.test(J)&&t.push(`User "${b.email}" passwordHashes.${P} is not in Better Auth scrypt format "<32hex>:<128hex>".`)}}ED(e.tenant.branding,t),TD(e.tenant,t);let _=ID(e.fields.flatMap(b=>b.sourceColumns));for(let b of _)r.push(`Source column "${b}" is mapped by more than one field.`);N4(e,t);let T=n.sourceColumns===void 0||e.source===void 0?void 0:O4(e,n.sourceColumns,t);return{ok:t.length===0,errors:t,warnings:r,coverage:T}}s($D,"validateTenantConfig");function v4(e,n){let t=new Map;for(let r of e.objectSchema?.properties??[]){let i=r.addressPart;if(i===void 0)continue;let o=`Object property "${e.key}.${r.key}"`;if(!Cy.includes(i)){n.push(`${o}: addressPart "${i}" is none of ${Cy.join(", ")}.`);continue}e.type!=="object"&&n.push(`${o}: only an object field stores an address (addressPart).`),r.type!=="string"&&n.push(`${o}: addressPart "${i}" needs a string property, not "${r.type}".`);let a=t.get(i);a!==void 0&&n.push(`${o}: addressPart "${i}" is already declared by "${e.key}.${a}".`),t.set(i,r.key)}}s(v4,"validateAddressParts");function x4(e,n){let t=e.relationshipKinds;if(t===void 0)return;if(e.type!=="relationship"){n.push(`Field "${e.key}" declares relationshipKinds, but only a relationship field carries them.`);return}let r=new Map((e.objectSchema?.properties??[]).map(i=>[i.key,i]));for(let i of t){let o=`Field "${e.key}" relationship kind "${i.key}"`;if(typeof i.key!="string"||i.key.trim()===""){n.push(`Field "${e.key}": a relationship kind needs a key.`);continue}for(let l of["de","en"])(i.label?.[l]??"").trim()===""&&n.push(`${o}: label.${l} is required \u2014 [i18n/missingTranslation] every shown text needs German and English.`);if(i.edge===null||typeof i.edge!="object"||Array.isArray(i.edge)){n.push(`${o}: edge must be an object.`);continue}i.sibling!==void 0&&i.sibling!==!0&&n.push(`${o}: sibling must be true or absent.`),i.sibling===!0&&i.mergeInto!==void 0&&n.push(`${o}: a sibling kind's edge is its identity \u2014 it cannot declare mergeInto.`);let a=t.flatMap(l=>l.mergeInto!==void 0?[l.mergeInto]:[]);if(i.sibling===!0&&a.some(l=>l in i.edge)&&n.push(`${o}: a sibling kind's edge is its identity \u2014 it cannot declare a property another kind of the field merges into.`),i.sibling===!0&&Object.keys(i.edge).length===0&&n.push(`${o}: a sibling kind's edge is its identity \u2014 an empty edge would count every edge of the field.`),i.mergeInto!==void 0){let l=r.get(i.mergeInto);l===void 0||l.type!=="0-n-select"?n.push(`${o}: mergeInto "${i.mergeInto}" must name a 0-n-select property of the field's objectSchema.`):Array.isArray(i.edge[i.mergeInto])||n.push(`${o}: mergeInto "${i.mergeInto}" must be set to a list in the edge.`)}}}s(x4,"validateRelationshipKinds");function S4(e,n,t){if(e.autoString===void 0){t.push(`Automatic field "${e.key}" must define autoString.`);return}e.allowMultiple===!0&&t.push(`Automatic field "${e.key}" must not allow multiple values.`),e.shareable===!0&&t.push(`Automatic field "${e.key}" must not be shareable.`),e.autoString.segments.length===0&&t.push(`Automatic field "${e.key}" must define at least one segment.`),e.autoString.segments.filter(i=>i.kind==="sequence").length!==1&&t.push(`Automatic field "${e.key}" must define exactly one sequence segment.`);for(let i of e.autoString.segments)if(i.kind==="literal"&&i.value.length===0&&t.push(`Automatic field "${e.key}" has an empty literal segment.`),i.kind==="sequence"&&(i.startAt!==void 0&&(!Number.isInteger(i.startAt)||i.startAt<1)&&t.push(`Automatic field "${e.key}" sequence startAt must be an integer >= 1.`),i.minDigits!==void 0&&(!Number.isInteger(i.minDigits)||i.minDigits<0)&&t.push(`Automatic field "${e.key}" sequence minDigits must be an integer >= 0.`)),i.kind==="field"){let o=n.get(i.fieldKey);if(o===void 0){t.push(`Automatic field "${e.key}" references missing field "${i.fieldKey}".`);continue}i.objectPropertyKey!==void 0&&o.objectSchema?.properties.find(l=>l.key===i.objectPropertyKey)===void 0&&t.push(`Automatic field "${e.key}" references missing object property "${i.fieldKey}.${i.objectPropertyKey}".`)}}s(S4,"validateAutomaticStringField");function zp(e,n,t,r){if(e===void 0)return;let i=n.get(e.fieldKey);if(i===void 0){t.push(`${r} references missing field "${e.fieldKey}".`);return}if(e.objectPropertyKey===void 0)return;(i.objectSchema?.properties.some(a=>a.key===e.objectPropertyKey)??!1)||t.push(`${r} references missing object property "${e.fieldKey}.${e.objectPropertyKey}".`)}s(zp,"validateSearchTarget");function A4(e,n,t){if(e.source.kind!=="relationshipTargetField")return;let r=`Template placeholder "${e.key}"`,i=n.get(e.source.relationshipFieldKey);if(i===void 0)t.push(`${r} references missing relationship field "${e.source.relationshipFieldKey}".`);else if(i.type!=="relationship")t.push(`${r} relationship field "${e.source.relationshipFieldKey}" must be a relationship field.`);else{for(let a of e.source.edgeFilters??[])$k(i,a.propertyKey,t,`${r} edge filter`);e.source.selection?.sortPropertyKey!==void 0&&$k(i,e.source.selection.sortPropertyKey,t,`${r} selection sort`)}let o=n.get(e.source.targetFieldKey);if(o===void 0){t.push(`${r} references missing target field "${e.source.targetFieldKey}".`);return}o.type==="relationship"&&t.push(`${r} target field "${e.source.targetFieldKey}" must not be a relationship field.`),e.source.targetObjectPropertyKey!==void 0&&$k(o,e.source.targetObjectPropertyKey,t,`${r} target`)}s(A4,"validateRelationshipTemplatePlaceholder");function $k(e,n,t,r){(e.objectSchema?.properties.some(o=>o.key===n)??!1)||t.push(`${r} references missing object property "${e.key}.${n}".`)}s($k,"validateObjectPropertyReference");function E4(e,n,t){let r=`Party result icon "${e.key}"`,i=n.get(e.when.fieldKey);if(i===void 0){t.push(`${r} references missing field "${e.when.fieldKey}".`);return}if(e.when.objectPropertyKey===void 0){i.type!=="boolean"&&t.push(`${r} must target a Boolean field or object property.`);return}let o=i.objectSchema?.properties.find(a=>a.key===e.when.objectPropertyKey);if(o===void 0){t.push(`${r} references missing object property "${e.when.fieldKey}.${e.when.objectPropertyKey}".`);return}o.type!=="boolean"&&t.push(`${r} must target a Boolean field or object property.`)}s(E4,"validatePartyResultIconTarget");function RD(e){return`${e.templateId}:${e.locale}:${e.scopeKey}`}s(RD,"letterIdentity");function T4(e){return`${e.generatorKey??"*"}/${e.partyKind}/${e.roleKey}`}s(T4,"contractRoleMappingIdentity");function $4(e,n,t){let r=new Set;for(let i of e){let o=T4(i),a=`Contract role mapping "${o}"`;hk.includes(i.partyKind)||t.push(`${a}: partyKind must be one of ${hk.join(", ")}.`),n.has(i.roleKey)||t.push(`${a} references missing role "${i.roleKey}".`),i.generatorKey!==void 0&&i.generatorKey.trim()===""&&t.push(`${a}: generatorKey must not be blank \u2014 omit it for the tenant default.`),r.has(o)&&t.push(`${a} is declared twice.`),r.add(o)}}s($4,"validateContractRoleMappings");function R4(e,n){for(let t of e){let r=`Notification letter "${RD(t)}"`;if(!Kp(t.locale)){n.push(`${r} declares locale "${String(t.locale)}" \u2014 letters are written in ${We.map(i=>`"${i}"`).join(" and ")} only, so no mail would ever read this deviation.`);continue}if(t.scopeKey!==Mp){n.push(`${r} declares scopeKey "${t.scopeKey}" \u2014 the only scope is "${Mp}" (the whole school).`);continue}if(Object.keys(t.slots).length===0){n.push(`${r} overrides no block. A deviation that deviates in nothing is not an entry \u2014 remove it.`);continue}if(!aw(t.templateId)){n.push(`${r} references no registered letter \u2014 "${t.templateId}" is not in the letter catalog.`);continue}for(let i of lD(sw(t.templateId),t.slots,t.locale))n.push(`${r}, block "${i.slotKey}" [${i.code}]: ${i.message.de}`)}}s(R4,"validateNotificationLetters");function I4(e,n){if(e!==void 0)for(let t of dD(e))n.push(`Notification chrome: ${t.de}`)}s(I4,"validateNotificationChrome");function ED(e,n,t){if(e===void 0)return;let r=t===void 0?n:{push:s((...p)=>n.push(...p.map(m=>`${t}: ${m}`)),"push")},i=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,o=/^(?:rgb|rgba|hsl|hsla)\(.+\)$/i,a=s(p=>i.test(p.trim())||o.test(p.trim()),"isColor");for(let[p,m]of Object.entries(e.colors??{}))m!==void 0&&(a(m)||r.push(`Branding color "colors.${p}" has invalid value "${m}" (expected hex "#rgb"/"#rrggbb"/"#rrggbbaa" or rgb()/rgba()/hsl()/hsla()).`));let l=["sharp","rounded","soft"];e.radius!==void 0&&!l.includes(e.radius)&&r.push(`Branding radius "${e.radius}" is invalid (expected "sharp", "rounded", or "soft").`);let d=["sm","md","lg","max"];e.logoSize!==void 0&&!d.includes(e.logoSize)&&r.push(`Branding logoSize "${e.logoSize}" is invalid (expected "sm", "md", "lg", or "max").`);let c=["compact","normal","spacious"];e.bannerDensity!==void 0&&!c.includes(e.bannerDensity)&&r.push(`Branding bannerDensity "${e.bannerDensity}" is invalid (expected "compact", "normal", or "spacious").`);let u=["light","dark"];e.logoGround!==void 0&&!u.includes(e.logoGround)&&r.push(`Branding logoGround "${e.logoGround}" is invalid (expected "light" or "dark").`),e.websiteUrl!==void 0&&!e.websiteUrl.startsWith("https://")&&r.push(`Branding websiteUrl must be an https:// URL (got "${e.websiteUrl}").`);for(let p of["heading","body"]){let m=e.fonts?.[p];m!==void 0&&((typeof m.family!="string"||m.family.trim().length===0)&&r.push(`Branding font "fonts.${p}" must define a non-empty family.`),Object.hasOwn(m,"url")&&r.push(`Branding font "fonts.${p}.url" is no longer supported \u2014 the font file is uploaded (plexus-cli branding set-font --slot ${p} --file <woff2>) and config carries the family only.`))}}s(ED,"validateBranding");function TD(e,n,t="tenant"){let r=e.brandingAssets;if(r!==void 0){if(typeof r!="object"||r===null||Array.isArray(r)){n.push(`${t}.brandingAssets must be an object keyed by slot (${Vp.join(", ")}).`);return}for(let[i,o]of Object.entries(r)){let a=`${t}.brandingAssets.${i}`;if(!Vp.includes(i)){n.push(`${a}: unknown slot (expected ${Vp.join(", ")}).`);continue}if(typeof o!="object"||o===null){n.push(`${a}: must be { sha256, sizeBytes, mimeType }.`);continue}if("size"in o){n.push(`[config/fileRefRenamed] ${a} still names size \u2014 this bundle was exported before the file-field rename, or by a plexus-cli older than this release (now sizeBytes). Update plexus-cli, export it again (plexus-cli --env <env> config export) and re-apply.`);continue}OD.test(o.sha256??"")||n.push(`${a}: sha256 must be 64 lowercase hex chars.`),(!Number.isInteger(o.sizeBytes)||o.sizeBytes<=0)&&n.push(`${a}: sizeBytes must be a positive integer.`);let l=fD[i];if(l===null){let d=pD({contentType:o.mimeType,size:o.sizeBytes});d!==null&&n.push(`${a}: ${d.de}`)}else{o.mimeType!==Ek&&n.push(`${a}: mimeType must be "${Ek}" (got "${o.mimeType}").`);let d=mD(e.branding?.fonts?.[l]?.family);d!==null&&n.push(`${a}: [branding/fontFamilyMissing] ${t}.branding.fonts.${l}: ${d.de}`)}"path"in o&&n.push(`${a}: "path" is a CLI snapshot field \u2014 resolve it with plexus-cli config apply.`)}}}s(TD,"validateBrandingAssets");function O4(e,n,t){let{source:r}=e;r===void 0&&F("validateSourceCoverage: called without a `source` block.");let i=new Set(n),o=new Set(e.fields.flatMap(k=>k.sourceColumns)),a=new Set(e.deferredColumns.map(k=>k.column)),l=new Set(e.ignoredColumns.map(k=>k.column)),d=new Set([...o,...a,...l]),c=r.requiredColumns.filter(k=>!i.has(k)),u=n.filter(k=>!d.has(k)),p=[...o].filter(k=>!i.has(k)),m=[...a].filter(k=>!i.has(k)),y=[...l].filter(k=>!i.has(k));for(let k of c)t.push(`Required source column "${k}" is missing from ${r.primaryTable}.`);for(let k of u)t.push(`Source column "${k}" is neither mapped nor explicitly deferred/ignored.`);for(let k of p)t.push(`Mapped source column "${k}" does not exist in the source schema.`);for(let k of m)t.push(`Deferred source column "${k}" does not exist in the source schema.`);for(let k of y)t.push(`Ignored source column "${k}" does not exist in the source schema.`);return{table:r.primaryTable,availableColumns:n.length,mappedColumns:[...o].filter(k=>i.has(k)).length,deferredColumns:[...a].filter(k=>i.has(k)).length,ignoredColumns:[...l].filter(k=>i.has(k)).length,missingRequiredColumns:c,unmappedColumns:u,unknownMappedColumns:p,unknownDeferredColumns:m,unknownIgnoredColumns:y}}s(O4,"validateSourceCoverage");function Tn(e,n,t){for(let r of ID(e))t.push(`Duplicate ${n} key "${r}".`)}s(Tn,"requireUnique");function ID(e){let n=new Set,t=new Set;for(let r of e)n.has(r)&&t.add(r),n.add(r);return[...t]}s(ID,"duplicates");var OD=/^[0-9a-f]{64}$/,P4=["fileName","size"];function N4(e,n){if(!Array.isArray(e.files)){n.push('"files" is missing \u2014 declare the file library (an empty list is fine).');return}Tn(e.files.map(t=>t.key),"file",n);for(let t of e.files){let r=`files["${t.key}"]`;oa(t.key)||n.push(`${r}: key must match ${Gw}.`);for(let o of["de","en"])(t.label?.[o]??"").trim()===""&&n.push(`${r}: label.${o} is required \u2014 [i18n/missingTranslation] every shown text needs German and English.`);let i=P4.filter(o=>o in t);if(i.length>0){n.push(`[config/fileRefRenamed] ${r} still names ${i.join(", ")} \u2014 this bundle was exported before the file-field rename, or by a plexus-cli older than this release (now filename / sizeBytes). Update plexus-cli, export it again (plexus-cli --env <env> config export) and re-apply.`);continue}if(typeof t.filename!="string")n.push(`${r}: filename is missing.`);else{let o=_o(t.filename);o!==null&&n.push(`${r}: filename ${o}.`)}qp.includes(t.mimeType)||n.push(`${r}: mimeType "${t.mimeType}" is not allowed (${qp.join(", ")}).`),OD.test(t.sha256??"")||n.push(`${r}: sha256 must be 64 lowercase hex chars.`),(!Number.isInteger(t.sizeBytes)||t.sizeBytes<=0)&&n.push(`${r}: sizeBytes must be a positive integer.`),"path"in t&&n.push(`${r}: "path" is a CLI snapshot field \u2014 resolve it with plexus-cli config apply.`)}}s(N4,"validateFiles");var _4=new WeakMap,C4=new WeakSet;function Rk(e,n){n(e);let r=e.asOptional.bind(e);return Object.defineProperty(e,"asOptional",{value:s(()=>Rk(r(),n),"value"),enumerable:!1}),e}s(Rk,"carry");function pa(e,n){return Rk(e,t=>_4.set(t,n))}s(pa,"tagged");var D4="tenant teardown drains every table explicitly (config/wipe.ts)",Yn={belongsTo:s(e=>pa(e,{kind:"belongsTo"}),"belongsTo"),owns:s(e=>pa(e,{kind:"owns"}),"owns"),holds:s(e=>pa(e,{kind:"holds"}),"holds"),restrict:s((e,n)=>pa(e,n?{kind:"restrict",unindexed:n.unindexed}:{kind:"restrict"}),"restrict"),history:s(e=>pa(e,{kind:"history"}),"history"),tenant:s(e=>pa(e,{kind:"restrict",unindexed:D4}),"tenant"),historyOf:s(e=>Rk(e,n=>C4.add(n)),"historyOf")};var F4=w.object({street:w.string(),hausnr:w.string(),plz:w.string(),ort:w.string()}),PD=w.union(w.literal("school_operator"),w.literal("school_group"),w.literal("service_entity")),Br=PD.members.map(e=>e.value),L4={tenantId:Yn.tenant(w.id("tenants")),name:w.optional(w.string()),type:PD,parentLegalEntityId:w.optional(Yn.restrict(w.id("legal_entities"))),configKey:w.optional(w.string()),partyId:w.optional(Yn.restrict(w.id("parties"))),address:w.optional(F4),signatoryUserId:w.optional(Yn.restrict(w.id("users"))),terms:w.optional(sD)},nSe=Jr(L4).index("by_tenantId",["tenantId"]).index("by_parentLegalEntityId",["parentLegalEntityId"]).index("by_tenantId_and_configKey",["tenantId","configKey"]).index("by_partyId",["partyId"]).index("by_signatoryUserId",["signatoryUserId"]);var M4=w.union(w.literal("school"),w.literal("kindergarten"),w.literal("after_school_care"),w.literal("department"),w.literal("site"),w.literal("other")),Ft=M4.members.map(e=>e.value),iSe=w.union(w.literal("school"),w.literal("vocational"),w.literal("care"),w.literal("seminar"),w.literal("other")),oSe=w.union(w.literal("none"),w.literal("manual"),w.literal("annual_rollover")),sSe=w.union(w.literal("grade_level"),w.literal("module"),w.literal("phase"),w.literal("other")),aSe=w.union(w.literal("school_year"),w.literal("cohort"),w.literal("seminar"),w.literal("care_period"),w.literal("other")),lSe=w.union(w.literal("planned"),w.literal("active"),w.literal("completed"),w.literal("archived")),dSe=w.union(w.literal("class"),w.literal("course"),w.literal("care_group"),w.literal("seminar_group"),w.literal("mixed_age_group"),w.literal("other")),cSe=w.union(w.literal("planned"),w.literal("active"),w.literal("completed"),w.literal("cancelled")),uSe=w.union(w.literal("class_teacher"),w.literal("teacher"),w.literal("mentor"),w.literal("instructor"),w.literal("assistant"),w.literal("other")),fSe=w.union(w.literal("units"),w.literal("unit_profiles"),w.literal("programs"),w.literal("program_stages"),w.literal("program_runs"),w.literal("learning_groups"),w.literal("enrollments"),w.literal("learning_group_staff_assignments")),pSe=w.union(w.literal("open"),w.literal("mapped"),w.literal("ignored"));function _D(e){let n=["street","hausnr","plz","ort"].filter(t=>e[t]!==void 0);if(n.length!==0){if(n.length!==4)throw new Error(`config legal-entity add: an address needs all of --street, --hausnr, --plz and --ort (got ${n.map(t=>`--${t}`).join(", ")})`);return{street:e.street,hausnr:e.hausnr,plz:e.plz,ort:e.ort}}}s(_D,"addressFrom");function CD(e){if(!Br.includes(e))throw new Error(`config legal-entity add: --type "${e}" is none of ${Br.join(", ")}`);return e}s(CD,"legalEntityType");function DD(e){if(!Ft.includes(e))throw new Error(`config unit add: --kind "${e}" is none of ${Ft.join(", ")}`);return e}s(DD,"unitKind");function FD(e,n,t){let r=e.find(i=>i.key===n.key);if(r===void 0)return e.push(n),"create";if(Pe(r)===Pe(n))return"same";throw new Error(`${t} "${n.key}" already exists with other values \u2014 decide by hand, nothing written.
|
|
11199
11202
|
in the file: ${JSON.stringify(r)}
|
|
11200
11203
|
requested: ${JSON.stringify(n)}`)}s(FD,"addRow");function ND(e){return new Set($D(e).errors)}s(ND,"findings");function LD(e,n){let t=s(()=>JSON.parse(he(e,"utf8")),"read"),r=t();if(typeof r!="object"||r===null||typeof r.foundation!="object")throw new Error(`config: ${e} is no exported tenant config (no "foundation" block) \u2014 export one with \`config export --out <file>\``);let i=ND(r),o=t(),a=n(o),l=[...ND(o)].filter(d=>!i.has(d));if(l.length>0)throw new Error(`config: the edit is refused by the config validator, nothing written:
|
|
11201
11204
|
${l.join(`
|
|
@@ -11203,27 +11206,27 @@ The Plexus team`}},CJ={de:{...Ql.de,closing:null},en:{...Ql.en,closing:null}};va
|
|
|
11203
11206
|
`,"utf8"),{...a,preexisting:[...i]}}s(LD,"editConfigFile");function MD(e,n){return{target:"legalEntities",key:n.key,action:FD(e.foundation.legalEntities,n,"Legal entity")}}s(MD,"addLegalEntity");function qD(e,n){return{target:"units",key:n.key,action:FD(e.foundation.units,n,"Unit")}}s(qD,"addUnit");var Ik="applicant";var KD="interessent";function jD(e,n){return{slug:e,name:n,enabledModules:[...QC],permissions:[...gk],defaultApplicantGroupKey:Ik,defaultInteressentRoleKey:KD,defaultStartInProxy:!1,mailLevel:"all",magicLinkLogin:!0,externalSignIn:{mode:"oneTimeLink"},nationalityFlag:{...wD},adminSeesSignatureImages:!1,signatureStamp:!0}}s(jD,"fullTenant");function BD(e){return{legalEntities:e.legalEntities,units:e.units,permissionGroups:[{key:"tenant_admin",label:Do("Mandantenadmin","Tenant Admin"),permissions:[...gk],sortOrder:10,grantAllCustomFields:!0},{key:Ik,label:Do("Extern/Bewerber","External/applicant"),permissions:[...XC],sortOrder:1e3}],users:e.users}}s(BD,"foundationWithTenantAdmin");function VD(e){let{slug:n,name:t}=e,r=`${n}_operator`,i=`${n}_schule`,o=BD({legalEntities:[{key:r,name:`${t} (Tr\xE4ger)`,type:"school_operator"}],units:[{key:i,name:{de:t,en:t},legalEntityKey:r,pedagogyUnit:!0,kind:"school"}],users:[]});return{key:n,tenant:{...jD(n,t),admissionFieldDisplayGroupKey:"stammdaten"},foundation:o,displayGroups:[{key:"stammdaten",label:{de:"Allgemein",en:"General"},color:"#475569",icon:"UserRound",sortOrder:10,defaultExpanded:!0}],lists:[],roles:[],fields:[],roleFields:[],deferredColumns:[],files:[],ignoredColumns:[]}}s(VD,"buildSkeletonTenantConfig");function Ok(e,n,t="password"){n.length!==0&&(Mo(e,t)||Ph(e,`email,${t}
|
|
11204
11207
|
`),Ph(e,n.map(r=>`${r.email},${r.password}
|
|
11205
11208
|
`).join("")))}s(Ok,"writeCredentialRows");function Mo(e,n){let t=`email,${n}`,r=Se(e)?he(e,"utf8"):"";if(r.trim().length===0)return!1;let i=r.split(`
|
|
11206
|
-
`,1)[0];if(i!==t)throw new Error(`plexus: ${e} is not an "${t}" file (header: "${i}") \u2014 pick another --out.`);return!0}s(Mo,"assertCredentialFile");function Wp(e,n,t,r="password"){Ok(e,[{email:n,password:t}],r)}s(Wp,"writeCredentialRow");var Lt={create:"+",update:"~",destroy:"-"};function UD(e,n=!1){let t=[{kind:`${Lt.create} create`,target:"(all)",detail:String(e.counts.created)},{kind:`${Lt.update} update`,target:"(all)",detail:String(e.counts.updated)},{kind:`${Lt.destroy} delete`,target:"(all)",detail:String(e.counts.deleted)},{kind:"\xB7 unchanged",target:"(all)",detail:String(e.counts.unchanged)}];for(let r of e.creations)t.push({kind:`${Lt.create} create`,target:r.target,detail:r.key});for(let r of e.updates)t.push({kind:`${Lt.update} update`,target:r.target,detail:r.key});for(let r of e.deletions)t.push({kind:`${Lt.destroy} delete`,target:r.target,detail:r.key});for(let r of e.slugChanges)t.push({kind:`${Lt.update} slug`,target:`units/${r.unitKey}`,detail:`${r.from} \u2192 ${r.to} (old URL /e/units/${r.from} no longer reaches this unit)`});for(let r of e.orphans)t.push({kind:`${Lt.destroy} orphan`,target:`${r.target}/${r.table}`,detail:`${r.key} (${e.destroyed!==void 0?"destroyed":"would destroy"})`});for(let r of e.accounts.minted)t.push({kind:`${Lt.create} account`,target:r.email,detail:n?"password: (not echoed)":`password: ${r.password}`});for(let r of e.accounts.pending)t.push({kind:"! no account",target:r,detail:"would get a generated password on --confirm"});return t}s(UD,"planRows");function Pk(e,n,t,r,i){return(e?.changed??[]).map(o=>({kind:`${Lt.update} ${n}`,target:`${t}/${o}`,detail:e?.unavailable.includes(o)?`content differs \u2014 NO bytes in this source; a commit needs them bundled or fails ${r}`:i?"content differs \u2014 would upload":"content uploaded"}))}s(Pk,"contentRows");async function
|
|
11207
|
-
`,"utf8"),this.print({created:this.tenant,out:t},r=>[{key:"created",value:r.created},{key:"out",value:r.out},{key:"next",value:`plexus config apply --tenant ${r.created} --from snapshot:${r.out} (dry-run; add --confirm to commit)`}]),0}},Ck=class extends D{static{s(this,"ConfigTargetsCommand")}static paths=[["config","targets"]];static usage=$.Usage({category:"Config",description:"List the config/data target registry + live row counts / Ziel-Register"});async execute(){let n=await this.caller(),t=n.tenant,r=await n.action(x.config.api.targets,{...t!==void 0?{tenant:t}:{}});return this.print(r,i=>i.targets.map(o=>({id:o.id,kind:o.kind,scope:o.scope,rows:String(o.totalRows),label:`${o.label.de} / ${o.label.en}`,dependsOn:(o.dependsOn??[]).join(",")||"-"})),["id","kind","scope","rows","label","dependsOn"]),0}},Dk=class extends D{static{s(this,"ConfigApplyCommand")}static paths=[["config","apply"]];static usage=$.Usage({category:"Config",description:"Reconcile a tenant/platform config (dry-run unless --confirm) / Konfiguration anwenden",details:"A committing apply on a tenant whose config carries `foundation.users` MINTS a login password for every one of them that has no account yet, and prints it once \u2014 so this command can return secrets. Use --output <file> (and --quiet) to keep them out of a shared terminal."});scope=f.String("--scope",{description:"Apply scope: tenant (default) | platform"});from=f.String("--from","blueprint",{description:"Source: blueprint | env:<srcEnv> | snapshot:<path>"});confirm=f.Boolean("--confirm",!1,{description:"Commit (else dry-run)"});allowDestructive=f.Boolean("--allow-destructive",!1,{description:"Permit destroying orphaned rows"});out=f.String("--out",{description:"Append the minted `email,password` rows to this CSV file (created with a header; never overwritten)."});retiredOutput=da();quiet=f.Boolean("--quiet",!1,{description:"Do not echo the password to stdout (use with --out)."});async execute(){let n=ca(this);n!==void 0&&Mo(n,"password");let t=await this.caller();if(this.scope==="platform"){let g=await t.action(x.config.api.applyPlatform,{confirm:this.confirm});return this.print(g,v=>[{kind:`${Lt.create} create`,target:"(platform)",detail:String(v.counts.created)},{kind:`${Lt.update} update`,target:"(platform)",detail:String(v.counts.updated)},{kind:"\xB7 unchanged",target:"(platform)",detail:String(v.counts.unchanged)},{kind:"mode",target:v.dryRun?"DRY-RUN":"COMMITTED",detail:v.note}]),0}let r=this.requireTenant(t),{source:i,config:o,bytesFor:a,brandingBytesFor:l}=await
|
|
11208
|
-
`,"utf8"),this.print({exported:t,out:r},a=>[{key:"exported",value:a.exported},{key:"out",value:a.out}]),0}},Lk=class extends D{static{s(this,"ConfigSetCommand")}static paths=[["config","set"]];static usage=$.Usage({category:"Config",description:"Patch ONE field of ONE config row (dry-run unless --confirm) / Einzelnes Feld setzen"});target=f.String("--target",{required:!0,description:"setField target (tenant|display-groups|fields|lists|roles|units|\u2026)"});key=f.String("--key",{required:!0,description:"Row key"});field=f.String("--field",{required:!0,description:"Dot-path field (e.g. label.de)"});value=f.String("--value",{required:!0,description:"New value (JSON or string)"});confirm=f.Boolean("--confirm",!1,{description:"Commit (else dry-run)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.action(x.config.api.setField,{tenant:t,target:this.target,key:this.key,field:this.field,value:
|
|
11209
|
+
`,1)[0];if(i!==t)throw new Error(`plexus: ${e} is not an "${t}" file (header: "${i}") \u2014 pick another --out.`);return!0}s(Mo,"assertCredentialFile");function Wp(e,n,t,r="password"){Ok(e,[{email:n,password:t}],r)}s(Wp,"writeCredentialRow");var Lt={create:"+",update:"~",destroy:"-"};function UD(e,n=!1){let t=[{kind:`${Lt.create} create`,target:"(all)",detail:String(e.counts.created)},{kind:`${Lt.update} update`,target:"(all)",detail:String(e.counts.updated)},{kind:`${Lt.destroy} delete`,target:"(all)",detail:String(e.counts.deleted)},{kind:"\xB7 unchanged",target:"(all)",detail:String(e.counts.unchanged)}];for(let r of e.creations)t.push({kind:`${Lt.create} create`,target:r.target,detail:r.key});for(let r of e.updates)t.push({kind:`${Lt.update} update`,target:r.target,detail:r.key});for(let r of e.deletions)t.push({kind:`${Lt.destroy} delete`,target:r.target,detail:r.key});for(let r of e.slugChanges)t.push({kind:`${Lt.update} slug`,target:`units/${r.unitKey}`,detail:`${r.from} \u2192 ${r.to} (old URL /e/units/${r.from} no longer reaches this unit)`});for(let r of e.orphans)t.push({kind:`${Lt.destroy} orphan`,target:`${r.target}/${r.table}`,detail:`${r.key} (${e.destroyed!==void 0?"destroyed":"would destroy"})`});for(let r of e.accounts.minted)t.push({kind:`${Lt.create} account`,target:r.email,detail:n?"password: (not echoed)":`password: ${r.password}`});for(let r of e.accounts.pending)t.push({kind:"! no account",target:r,detail:"would get a generated password on --confirm"});return t}s(UD,"planRows");function Pk(e,n,t,r,i){return(e?.changed??[]).map(o=>({kind:`${Lt.update} ${n}`,target:`${t}/${o}`,detail:e?.unavailable.includes(o)?`content differs \u2014 NO bytes in this source; a commit needs them bundled or fails ${r}`:i?"content differs \u2014 would upload":"content uploaded"}))}s(Pk,"contentRows");async function K4(e,n){if(e==="blueprint")return{source:"blueprint"};if(e.startsWith("env:")){let t=e.slice(4);if(!t)throw new Error("config: --from env:<srcEnv> needs a source environment.");let r=await al({env:t,tenant:n});return{source:"inline",config:await r.query(x.config.api.exportTenant,{tenant:n}),bytesFor:s(async o=>{let a=(await Gl(r,n)).find(l=>l.key===o.key);return a===void 0?void 0:await Hw(a)},"bytesFor"),brandingBytesFor:s(async(o,a)=>{let l=(await Tp(r,n,a))?.[o];return l===void 0?void 0:await Jw(o,l,a)},"brandingBytesFor")}}if(e.startsWith("snapshot:")){let t=z.resolve(e.slice(9)),r=JSON.parse(he(t,"utf8")),{config:i,bytes:o,brandingBytes:a,legalEntityBrandingBytes:l}=dC(r,z.dirname(t));return{source:"inline",config:i,bytesFor:s(async d=>o.get(d.key)?.bytes,"bytesFor"),brandingBytesFor:s(async(d,c)=>(c===void 0?a:l.get(c))?.get(d)?.bytes,"brandingBytesFor")}}throw new Error(`config: unknown --from "${e}". Use blueprint | env:<srcEnv> | snapshot:<path>. / Unbekannte Quelle "${e}".`)}s(K4,"resolveSource");function j4(e){try{return JSON.parse(e)}catch{return e}}s(j4,"parseValue");var Nk=class extends xe{static{s(this,"ConfigShowCommand")}static paths=[["config","show"]];static usage=$.Usage({category:"Config",description:"Show the resolved connection config (no network) / Verbindung anzeigen"});env=f.String("--env",{description:"Target environment (local|staging|prod)"});tenant=f.String("--tenant",{description:"Tenant slug"});async execute(){let n=IR({env:this.env,tenant:this.tenant});return this.print({env:n.env,source:n.source,convexUrl:n.convexUrl,siteUrl:n.siteUrl,deployment:n.deployment??"(n/a)",tenant:n.tenant??"(none)",authMode:n.authMode,envVars:n.fromEnvVars.join(", ")||"(none)"},t=>[{key:"env",value:t.env},{key:"source",value:t.source},{key:"convexUrl",value:t.convexUrl},{key:"siteUrl",value:t.siteUrl},{key:"deployment",value:t.deployment},{key:"tenant",value:t.tenant},{key:"authMode",value:t.authMode},{key:"envVars",value:t.envVars}],["key","value"]),0}},_k=class extends xe{static{s(this,"ConfigInitCommand")}static paths=[["config","init"]];static usage=$.Usage({category:"Config",description:"Scaffold a minimal, valid tenant config JSON on disk / Mandanten-Konfiguration anlegen"});tenant=f.String("--tenant",{required:!0,description:"New tenant slug"});name=f.String("--name",{required:!0,description:"Tenant display name"});out=f.String("--out",{description:"Output file (default: config/.dev/<tenant>/config.json; refused when it exists, unless --force)"});force=kn();async execute(){let n=VD({slug:this.tenant,name:this.name}),t=_n(this.out??z.join(dn()?.workspaceRoot??ol,"config",".dev",this.tenant,"config.json"),this.force);return Fn(z.dirname(t),{recursive:!0}),ze(t,`${JSON.stringify(n,null,2)}
|
|
11210
|
+
`,"utf8"),this.print({created:this.tenant,out:t},r=>[{key:"created",value:r.created},{key:"out",value:r.out},{key:"next",value:`plexus config apply --tenant ${r.created} --from snapshot:${r.out} (dry-run; add --confirm to commit)`}]),0}},Ck=class extends D{static{s(this,"ConfigTargetsCommand")}static paths=[["config","targets"]];static usage=$.Usage({category:"Config",description:"List the config/data target registry + live row counts / Ziel-Register"});async execute(){let n=await this.caller(),t=n.tenant,r=await n.action(x.config.api.targets,{...t!==void 0?{tenant:t}:{}});return this.print(r,i=>i.targets.map(o=>({id:o.id,kind:o.kind,scope:o.scope,rows:String(o.totalRows),label:`${o.label.de} / ${o.label.en}`,dependsOn:(o.dependsOn??[]).join(",")||"-"})),["id","kind","scope","rows","label","dependsOn"]),0}},Dk=class extends D{static{s(this,"ConfigApplyCommand")}static paths=[["config","apply"]];static usage=$.Usage({category:"Config",description:"Reconcile a tenant/platform config (dry-run unless --confirm) / Konfiguration anwenden",details:"A committing apply on a tenant whose config carries `foundation.users` MINTS a login password for every one of them that has no account yet, and prints it once \u2014 so this command can return secrets. Use --output <file> (and --quiet) to keep them out of a shared terminal."});scope=f.String("--scope",{description:"Apply scope: tenant (default) | platform"});from=f.String("--from","blueprint",{description:"Source: blueprint | env:<srcEnv> | snapshot:<path>"});confirm=f.Boolean("--confirm",!1,{description:"Commit (else dry-run)"});allowDestructive=f.Boolean("--allow-destructive",!1,{description:"Permit destroying orphaned rows"});out=f.String("--out",{description:"Append the minted `email,password` rows to this CSV file (created with a header; never overwritten)."});retiredOutput=da();quiet=f.Boolean("--quiet",!1,{description:"Do not echo the password to stdout (use with --out)."});async execute(){let n=ca(this);n!==void 0&&Mo(n,"password");let t=await this.caller();if(this.scope==="platform"){let g=await t.action(x.config.api.applyPlatform,{confirm:this.confirm});return this.print(g,v=>[{kind:`${Lt.create} create`,target:"(platform)",detail:String(v.counts.created)},{kind:`${Lt.update} update`,target:"(platform)",detail:String(v.counts.updated)},{kind:"\xB7 unchanged",target:"(platform)",detail:String(v.counts.unchanged)},{kind:"mode",target:v.dryRun?"DRY-RUN":"COMMITTED",detail:v.note}]),0}let r=this.requireTenant(t),{source:i,config:o,bytesFor:a,brandingBytesFor:l}=await K4(this.from,r),d=o!==void 0&&a!==void 0?await uC(t,r,o.files??[],a,!this.confirm):void 0,c=o!==void 0&&l!==void 0?await Yw(t,r,o.tenant.brandingAssets,l,!this.confirm):void 0,u=[];if(o!==void 0&&l!==void 0)for(let g of o.foundation?.legalEntities??[])g.brandingAssets!==void 0&&u.push({key:g.key,staged:await Yw(t,r,g.brandingAssets,v=>l(v,g.key),!this.confirm,g.key)});let p=Object.fromEntries(u.filter(({staged:g})=>Object.keys(g.contents).length>0).map(({key:g,staged:v})=>[g,v.contents])),m=await t.action(x.config.api.apply,{tenant:r,...i!==void 0?{source:i}:{},...o!==void 0?{config:o}:{},...d!==void 0&&Object.keys(d.contents).length>0?{fileContents:d.contents}:{},...c!==void 0&&Object.keys(c.contents).length>0?{brandingContents:c.contents}:{},...Object.keys(p).length>0?{legalEntityBrandingContents:p}:{},confirm:this.confirm,allowDestructive:this.allowDestructive}),y=m.accounts.minted,k=n!==void 0&&y.length>0;return n!==void 0&&Ok(n,y),this.print(m,g=>[...UD(g,this.quiet),...Pk(d,"file","files","[file/contentMissing]",g.dryRun),...Pk(c,"brand","branding","[branding/contentMissing]",g.dryRun),...u.flatMap(({key:v,staged:E})=>Pk(E,"brand",`branding/${v}`,"[branding/contentMissing]",g.dryRun)),{kind:"mode",target:g.dryRun?"DRY-RUN":"COMMITTED",detail:`from=${this.from}${k?` \u2192 ${n}`:""}`}]),0}},Fk=class extends D{static{s(this,"ConfigExportCommand")}static paths=[["config","export"]];static usage=$.Usage({category:"Config",description:"Snapshot a tenant's live config to config/.dev/<tenant>/config.json / Konfiguration exportieren"});out=f.String("--out",{description:"Output file (default: config/.dev/<tenant>/config.json; refused when it exists, unless --force)"});force=kn();async execute(){let n=await this.caller(),t=this.requireTenant(n),r=kC(this.out??z.join(dn()?.workspaceRoot??ol,"config",".dev",t,"config.json"),["files","branding"],this.force),i=await n.query(x.config.api.exportTenant,{tenant:t});Fn(z.dirname(r),{recursive:!0});let o=await hC(n,t,i,r);return ze(r,`${JSON.stringify(o,null,2)}
|
|
11211
|
+
`,"utf8"),this.print({exported:t,out:r},a=>[{key:"exported",value:a.exported},{key:"out",value:a.out}]),0}},Lk=class extends D{static{s(this,"ConfigSetCommand")}static paths=[["config","set"]];static usage=$.Usage({category:"Config",description:"Patch ONE field of ONE config row (dry-run unless --confirm) / Einzelnes Feld setzen"});target=f.String("--target",{required:!0,description:"setField target (tenant|display-groups|fields|lists|roles|units|\u2026)"});key=f.String("--key",{required:!0,description:"Row key"});field=f.String("--field",{required:!0,description:"Dot-path field (e.g. label.de)"});value=f.String("--value",{required:!0,description:"New value (JSON or string)"});confirm=f.Boolean("--confirm",!1,{description:"Commit (else dry-run)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.action(x.config.api.setField,{tenant:t,target:this.target,key:this.key,field:this.field,value:j4(this.value),confirm:this.confirm});return this.print(r,i=>[{kind:"edit",target:`${this.target}/${this.key}`,detail:`${this.field}=${this.value}`},...UD(i),{kind:"mode",target:i.dryRun?"DRY-RUN":"COMMITTED",detail:""}]),0}},Mk=class extends D{static{s(this,"ConfigWipeCommand")}static paths=[["config","wipe"]];static usage=$.Usage({category:"Config",description:"Clear a target's tables (--confirm + --allow-destructive) / Ziel leeren",details:"Only `--target all` deletes the tenant identity row (full teardown). `--target foundation` clears foundation child tables (+ dependent DATA with --cascade) but leaves the `tenants` row and sibling config targets. Without --confirm it is a dry run: it prints, per table, the rows the wipe would clear (and any block it would hit) and deletes nothing."});target=f.String("--target",{required:!0,description:"Target id (or 'all' for full tenant teardown)"});cascade=f.Boolean("--cascade",!1,{description:"Also clear dependent targets"});confirm=f.Boolean("--confirm",!1,{description:"Required: actually wipe"});allowDestructive=f.Boolean("--allow-destructive",!1,{description:"Required for destructive wipes"});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(this.target!=="all"&&this.context.stderr.write(`note: '--target ${this.target}' leaves the tenant identity row and sibling config targets intact; use '--target all' for a full tenant teardown.
|
|
11209
11212
|
`),!this.confirm){let i=await n.action(x.config.api.wipePreview,{tenant:t,target:this.target,cascade:this.cascade});return this.print({dryRun:!0,tenant:t,...i},o=>[...o.perTable.map(a=>({table:`${a.target}.${a.table}`,deleted:`would clear ${a.rows}`})),...this.target==="all"?[{table:"tenants",deleted:`would delete the tenant "${t}" itself`}]:[],...o.blocked!==void 0?[{table:"BLOCKED",deleted:o.blocked}]:[],{table:"(dry run)",deleted:"add --confirm (+ --allow-destructive for heavy targets) to wipe"}]),0}let r=await n.action(x.config.api.wipe,{tenant:t,target:this.target,cascade:this.cascade,confirm:this.confirm,allowDestructive:this.allowDestructive});return this.print(r,i=>i.blocked?[{table:"BLOCKED",deleted:i.blocked}]:[{table:"(targets)",deleted:i.clearedTargets.join(",")||"-"},...i.perTable.map(o=>({table:o.table,deleted:String(o.deleted)}))]),0}},qk=class extends D{static{s(this,"ConfigPruneOffersCommand")}static paths=[["config","prune-offers"]];static usage=$.Usage({category:"Config",description:"Drop offer generations that are only edit history / Tote Angebots-Generationen entfernen",details:"A generation is prunable only when ALL of these hold: its status is `archived`, NO application is pinned to it, and it is not the last generation of its key. A `wip` draft and a published head are never touched, however few applications sit on them. Dry-run unless --confirm."});confirm=f.Boolean("--confirm",!1,{description:"Required: actually delete the listed generations"});async execute(){let n=await this.caller(),t=this.requireTenant(n),i=await n.action(x.config.api.pruneOffers,{tenant:t,commit:this.confirm});return this.print(i,()=>[...i.prunable.map(o=>({verdict:i.committed?"deleted":"would delete",offer:`${o.key} r${o.revision}`,label:o.label})),...i.keptWithApplications.map(o=>({verdict:"kept (applications)",offer:`${o.key} r${o.revision}`,label:o.label})),{verdict:i.committed?`deleted ${i.deleted}`:`dry run (${i.prunable.length})`,offer:`${i.scanned} generations scanned`,label:""}]),0}},GD="Edits an EXPORTED config file (`config export --out <file>`) offline; nothing reaches an environment until `config apply --from snapshot:<file>` (dry run) and `--confirm`. Adds by stable key: the same row again is a no-op, another row under the key is refused naming both (nothing overwritten). The edited file must pass the validator `config apply` runs; an edit that adds a finding is not written.",Yp=class extends Ti{static{s(this,"FoundationEditCommand")}file=f.String("--file",{required:!0,description:"Exported config.json (edited in place)"});run(n){let t=LD(z.resolve(this.file),n);for(let r of t.preexisting)this.context.stderr.write(` \u26A0 vorbestehend, nicht durch diese \xC4nderung: ${r}
|
|
11210
|
-
`);return this.print({target:t.target,key:t.key,action:t.action,file:this.file},r=>[{kind:r.action==="create"?`${Lt.create} create`:"\xB7 same",target:r.target,detail:r.key},{kind:"next",target:"(file)",detail:`config apply --tenant <slug> --from snapshot:${r.file} (dry run; --confirm commits)`}]),0}},Kk=class extends Yp{static{s(this,"ConfigLegalEntityAddCommand")}static paths=[["config","legal-entity","add"]];static usage=$.Usage({category:"Config",description:"Add a legal entity (Tr\xE4ger) to an exported config file \u2014 offline / Tr\xE4ger hinzuf\xFCgen",details:`${GD} Only a Tr\xE4ger (school_operator, service_entity) carries an address \u2014 all four parts or none; contracts print it as the Tr\xE4ger's Anschrift.`,examples:[["A care Tr\xE4ger with its address","$0 config legal-entity add --file ./config.json --key demo-care-gmbh --name 'Demo Betreuung gGmbH' --type service_entity --street Musterweg --hausnr 1 --plz 12345 --ort Musterstadt"]]});key=f.String("--key",{required:!0,description:"Stable key (never the name)"});name=f.String("--name",{required:!0,description:"Legal name"});type=f.String("--type",{required:!0,description:Br.join(" | ")});parent=f.String("--parent",{description:"Parent legal entity key"});street=f.String("--street",{description:"Address: street"});hausnr=f.String("--hausnr",{description:"Address: house number"});plz=f.String("--plz",{description:"Address: postcode"});ort=f.String("--ort",{description:"Address: town"});async execute(){let n=_D({street:this.street,hausnr:this.hausnr,plz:this.plz,ort:this.ort}),t={key:this.key,name:this.name,type:CD(this.type),...this.parent!==void 0?{parentLegalEntityKey:this.parent}:{},...n!==void 0?{address:n}:{}};return this.run(r=>MD(r,t))}},jk=class extends Yp{static{s(this,"ConfigUnitAddCommand")}static paths=[["config","unit","add"]];static usage=$.Usage({category:"Config",description:"Add a unit (Einrichtung) to an exported config file \u2014 offline / Einrichtung hinzuf\xFCgen",details:`${GD} The unit's Tr\xE4ger (--legal-entity) must exist in the file \u2014 add it first with \`config legal-entity add\`.`,examples:[["An after-school care unit","$0 config unit add --file ./config.json --key demo-hort --name 'Hort Demo' --name-en 'After-school care Demo' --legal-entity demo-care-gmbh --kind after_school_care --pedagogy-unit"]]});key=f.String("--key",{required:!0,description:"Stable key (never the name)"});name=f.String("--name",{required:!0,description:"German name"});nameEn=f.String("--name-en",{required:!0,description:"English name"});legalEntity=f.String("--legal-entity",{required:!0,description:"The Tr\xE4ger's key"});kind=f.String("--kind",{required:!0,description:Ft.join(" | ")});slug=f.String("--slug",{description:"URL slug (default: derived from the German name on create)"});parent=f.String("--parent",{description:"Parent unit key"});pedagogyUnit=f.Boolean("--pedagogy-unit",!1,{description:"A pedagogical unit (shown in the portal)"});async execute(){let n={key:this.key,name:{de:this.name,en:this.nameEn},legalEntityKey:this.legalEntity,kind:DD(this.kind),...this.pedagogyUnit?{pedagogyUnit:!0}:{},...this.slug!==void 0?{slug:this.slug}:{},...this.parent!==void 0?{parentUnitKey:this.parent}:{}};return this.run(t=>qD(t,n))}},zD=[Nk,_k,Kk,jk,Ck,Dk,Fk,Lk,Mk,qk];var Bk=["sibling","stipend","promo","needsBased","singleParent"],Hp=class extends D{static{s(this,"GrantSourceCommand")}template=f.String("--template",{description:"Grant template configKey (its terms are copied)"});name=f.String("--name",{description:"One-off grant: display name (German)"});reason=f.String("--reason",{description:`One-off grant: ${Bk.join("|")}`});percent=f.String("--percent",{description:"One-off grant: percent off"});amount=f.String("--amount",{description:"One-off grant: euro off (a line, never a package)"});evidence=f.String("--evidence",{required:!0,description:'Why the family gets it, as a JSON object \u2014 e.g. {"rank":2,"proof":"Bescheid Stadt 03.11."}'});parsedEvidence(){let n;try{n=JSON.parse(this.evidence)}catch{throw new Error("--evidence must be a JSON object.")}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("--evidence must be a JSON object.");return n}source(){if(this.template!==void 0){if(this.name!==void 0||this.percent!==void 0||this.amount!==void 0)throw new Error("Either --template or --name/--reason/--percent|--amount, not both.");return{kind:"template",configKey:this.template}}if(this.name===void 0||this.reason===void 0||this.percent===void 0==(this.amount===void 0))throw new Error("A one-off grant needs --name, --reason and exactly one of --percent / --amount.");if(!Bk.includes(this.reason))throw new Error(`--reason must be one of ${Bk.join("|")}.`);let n=Number(this.percent??this.amount);if(!Number.isFinite(n))throw new Error("--percent/--amount must be a number.");return{kind:"terms",name:this.name,reason:this.reason,grantKind:this.percent!==void 0?"percent":"absolute",value:n}}},Vk=class extends Hp{static{s(this,"ContractGrantAddCommand")}static paths=[["contract","grant","add"]];static usage=$.Usage({category:"Contracts",description:"Add a grant to one contract line (--line) from the 1st of a month.",examples:[["City rank 2 from November",`$0 contract grant add --env staging --tenant test --line <lineId> --template city-sibling-2 --from 2026-11-01 --evidence '{"rank":2}'`]]});line=f.String("--line",{description:"contract_lines id"});from=f.String("--from",{required:!0,description:"First day (YYYY-MM-01)"});to=f.String("--to",{description:"Last day (last day of a month)"});async execute(){if(!this.line)throw new Error("Name --line. Aggregate grants target explicit contract lines through contractGrants:addAggregate.");let n={kind:"line",contractLineId:this.line},t=await this.caller();return this.print(await t.mutation(x.contractGrants.add,{client:this.requireTenant(t),target:n,source:this.source(),eligibilityEvidence:this.parsedEvidence(),activeFrom:this.from,...this.to===void 0?{}:{activeTo:this.to}})),0}},Uk=class extends D{static{s(this,"ContractGrantEndCommand")}static paths=[["contract","grant","end"]];static usage=$.Usage({category:"Contracts",description:"End an applied grant on the last day of a month."});grant=f.String({required:!0,name:"appliedGrantId"});to=f.String("--to",{required:!0,description:"Last day (last day of a month)"});async execute(){let n=await this.caller();return this.print(await n.mutation(x.contractGrants.end,{client:this.requireTenant(n),appliedGrantId:this.grant,activeTo:this.to})),0}},Gk=class extends Hp{static{s(this,"ContractGrantReplaceCommand")}static paths=[["contract","grant","replace"]];static usage=$.Usage({category:"Contracts",description:"Replace an applied grant from the 1st of a month: the old one ends the day before, the new one takes its place."});grant=f.String({required:!0,name:"appliedGrantId"});from=f.String("--from",{required:!0,description:"First day of the new grant (YYYY-MM-01)"});async execute(){let n=await this.caller();return this.print(await n.mutation(x.contractGrants.replace,{client:this.requireTenant(n),appliedGrantId:this.grant,from:this.from,source:this.source(),eligibilityEvidence:this.parsedEvidence()})),0}},zk=class extends D{static{s(this,"ContractGrantAddAggregateCommand")}static paths=[["contract","grant","add-aggregate"]];static usage=$.Usage({category:"Contracts",description:"Apply a contract grant template to its eligible contract lines, with an optional agreed euro amount and floor."});contract=f.String("--contract",{required:!0,description:"contracts id"});template=f.String("--template",{required:!0,description:"Aggregate grant template configKey"});amount=f.String("--amount",{description:"Agreed euro deduction for the stated period"});floor=f.String("--floor",{description:"Agreed euro floor for the stated period"});period=f.String("--period",{description:"month|year|once|unit; changing period requires an explicit floor"});from=f.String("--from",{required:!0,description:"First day (YYYY-MM-01)"});to=f.String("--to",{description:"Last day (last day of a month)"});evidence=f.String("--evidence",{required:!0,description:"Finance decision and supporting evidence as a JSON object"});async execute(){let n=s(l=>{if(!/^(0|[1-9]\d*)(\.\d{1,2})?$/.test(l))throw new Error("Amounts must be nonnegative euros with at most two decimal places.");let d=Math.round(Number(l)*100);if(!Number.isSafeInteger(d))throw new Error("Amount is too large.");return d},"money");if(this.period!==void 0&&!ik.includes(this.period))throw new Error("--period must be month|year|once|unit.");let t;try{t=JSON.parse(this.evidence)}catch{throw new Error("--evidence must be a JSON object.")}if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("--evidence must be a JSON object.");let r=await this.caller(),i=this.requireTenant(r),a=(await r.query(x.contractConfig.model,{client:i})).grantTemplates.find(l=>l.configKey===this.template);if(!a||a.scope!=="aggregate")throw new Error("Name an existing aggregate grant template.");return this.print(await r.mutation(x.contractGrants.addAggregate,{client:i,contractId:this.contract,templateId:a.id,...this.amount===void 0?{}:{requestedAmountMinor:n(this.amount)},...this.floor===void 0?{}:{agreedFloorTotal:n(this.floor)},...this.period===void 0?{}:{pricePeriod:this.period},activeFrom:this.from,...this.to===void 0?{}:{activeTo:this.to},eligibilityEvidence:t})),0}},WD=[Vk,zk,Uk,Gk];import{readFileSync as W6,writeFileSync as Y6}from"node:fs";var Wk=[",",";"," "];function YD(e){let n=e.startsWith("\uFEFF")?e.slice(1):e;if(n.trim().length===0)throw new Error("The import file is empty.");let t=B6(n),r=V6(n,t),i=r[0];if(!i||i.cells.every(l=>l.trim().length===0))throw new Error("The import file needs a header row.");let o=U6(i.cells),a=r.slice(1).map(l=>{let d={};return o.forEach((c,u)=>{d[c]=l.cells[u]??""}),{rowNumber:l.lineNumber,values:d,cells:o.map((c,u)=>l.cells[u]??""),width:l.cells.length}});return{delimiter:t,columns:o,rows:a}}s(YD,"parseDelimitedText");function B6(e){let n=new Map(Wk.map(i=>[i,0])),t=!1;for(let i=0;i<e.length;i++){let o=e[i];if(o===void 0)break;if(o==='"'){if(t&&e[i+1]==='"'){i++;continue}t=!t;continue}if(!t&&(o===`
|
|
11211
|
-
`||o==="\r"))break;!t&&
|
|
11213
|
+
`);return this.print({target:t.target,key:t.key,action:t.action,file:this.file},r=>[{kind:r.action==="create"?`${Lt.create} create`:"\xB7 same",target:r.target,detail:r.key},{kind:"next",target:"(file)",detail:`config apply --tenant <slug> --from snapshot:${r.file} (dry run; --confirm commits)`}]),0}},Kk=class extends Yp{static{s(this,"ConfigLegalEntityAddCommand")}static paths=[["config","legal-entity","add"]];static usage=$.Usage({category:"Config",description:"Add a legal entity (Tr\xE4ger) to an exported config file \u2014 offline / Tr\xE4ger hinzuf\xFCgen",details:`${GD} Only a Tr\xE4ger (school_operator, service_entity) carries an address \u2014 all four parts or none; contracts print it as the Tr\xE4ger's Anschrift.`,examples:[["A care Tr\xE4ger with its address","$0 config legal-entity add --file ./config.json --key demo-care-gmbh --name 'Demo Betreuung gGmbH' --type service_entity --street Musterweg --hausnr 1 --plz 12345 --ort Musterstadt"]]});key=f.String("--key",{required:!0,description:"Stable key (never the name)"});name=f.String("--name",{required:!0,description:"Legal name"});type=f.String("--type",{required:!0,description:Br.join(" | ")});parent=f.String("--parent",{description:"Parent legal entity key"});street=f.String("--street",{description:"Address: street"});hausnr=f.String("--hausnr",{description:"Address: house number"});plz=f.String("--plz",{description:"Address: postcode"});ort=f.String("--ort",{description:"Address: town"});async execute(){let n=_D({street:this.street,hausnr:this.hausnr,plz:this.plz,ort:this.ort}),t={key:this.key,name:this.name,type:CD(this.type),...this.parent!==void 0?{parentLegalEntityKey:this.parent}:{},...n!==void 0?{address:n}:{}};return this.run(r=>MD(r,t))}},jk=class extends Yp{static{s(this,"ConfigUnitAddCommand")}static paths=[["config","unit","add"]];static usage=$.Usage({category:"Config",description:"Add a unit (Einrichtung) to an exported config file \u2014 offline / Einrichtung hinzuf\xFCgen",details:`${GD} The unit's Tr\xE4ger (--legal-entity) must exist in the file \u2014 add it first with \`config legal-entity add\`.`,examples:[["An after-school care unit","$0 config unit add --file ./config.json --key demo-hort --name 'Hort Demo' --name-en 'After-school care Demo' --legal-entity demo-care-gmbh --kind after_school_care --pedagogy-unit"]]});key=f.String("--key",{required:!0,description:"Stable key (never the name)"});name=f.String("--name",{required:!0,description:"German name"});nameEn=f.String("--name-en",{required:!0,description:"English name"});legalEntity=f.String("--legal-entity",{required:!0,description:"The Tr\xE4ger's key"});kind=f.String("--kind",{required:!0,description:Ft.join(" | ")});slug=f.String("--slug",{description:"URL slug (default: derived from the German name on create)"});parent=f.String("--parent",{description:"Parent unit key"});pedagogyUnit=f.Boolean("--pedagogy-unit",!1,{description:"A pedagogical unit (shown in the portal)"});async execute(){let n={key:this.key,name:{de:this.name,en:this.nameEn},legalEntityKey:this.legalEntity,kind:DD(this.kind),...this.pedagogyUnit?{pedagogyUnit:!0}:{},...this.slug!==void 0?{slug:this.slug}:{},...this.parent!==void 0?{parentUnitKey:this.parent}:{}};return this.run(t=>qD(t,n))}},zD=[Nk,_k,Kk,jk,Ck,Dk,Fk,Lk,Mk,qk];var Bk=["sibling","stipend","promo","needsBased","singleParent"],Hp=class extends D{static{s(this,"GrantSourceCommand")}template=f.String("--template",{description:"Grant template configKey (its terms are copied)"});name=f.String("--name",{description:"One-off grant: display name (German)"});reason=f.String("--reason",{description:`One-off grant: ${Bk.join("|")}`});percent=f.String("--percent",{description:"One-off grant: percent off"});amount=f.String("--amount",{description:"One-off grant: euro off (a line, never a package)"});evidence=f.String("--evidence",{required:!0,description:'Why the family gets it, as a JSON object \u2014 e.g. {"rank":2,"proof":"Bescheid Stadt 03.11."}'});parsedEvidence(){let n;try{n=JSON.parse(this.evidence)}catch{throw new Error("--evidence must be a JSON object.")}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("--evidence must be a JSON object.");return n}source(){if(this.template!==void 0){if(this.name!==void 0||this.percent!==void 0||this.amount!==void 0)throw new Error("Either --template or --name/--reason/--percent|--amount, not both.");return{kind:"template",configKey:this.template}}if(this.name===void 0||this.reason===void 0||this.percent===void 0==(this.amount===void 0))throw new Error("A one-off grant needs --name, --reason and exactly one of --percent / --amount.");if(!Bk.includes(this.reason))throw new Error(`--reason must be one of ${Bk.join("|")}.`);let n=Number(this.percent??this.amount);if(!Number.isFinite(n))throw new Error("--percent/--amount must be a number.");return{kind:"terms",name:this.name,reason:this.reason,grantKind:this.percent!==void 0?"percent":"absolute",value:n}}},Vk=class extends Hp{static{s(this,"ContractGrantAddCommand")}static paths=[["contract","grant","add"]];static usage=$.Usage({category:"Contracts",description:"Add a grant to one contract line (--line) from the 1st of a month.",examples:[["City rank 2 from November",`$0 contract grant add --env staging --tenant test --line <lineId> --template city-sibling-2 --from 2026-11-01 --evidence '{"rank":2}'`]]});line=f.String("--line",{description:"contract_lines id"});from=f.String("--from",{required:!0,description:"First day (YYYY-MM-01)"});to=f.String("--to",{description:"Last day (last day of a month)"});async execute(){if(!this.line)throw new Error("Name --line. Aggregate grants target explicit contract lines through contractGrants:addAggregate.");let n={kind:"line",contractLineId:this.line},t=await this.caller();return this.print(await t.mutation(x.contractGrants.add,{client:this.requireTenant(t),target:n,source:this.source(),eligibilityEvidence:this.parsedEvidence(),activeFrom:this.from,...this.to===void 0?{}:{activeTo:this.to}})),0}},Uk=class extends D{static{s(this,"ContractGrantEndCommand")}static paths=[["contract","grant","end"]];static usage=$.Usage({category:"Contracts",description:"End an applied grant on the last day of a month."});grant=f.String({required:!0,name:"appliedGrantId"});to=f.String("--to",{required:!0,description:"Last day (last day of a month)"});async execute(){let n=await this.caller();return this.print(await n.mutation(x.contractGrants.end,{client:this.requireTenant(n),appliedGrantId:this.grant,activeTo:this.to})),0}},Gk=class extends Hp{static{s(this,"ContractGrantReplaceCommand")}static paths=[["contract","grant","replace"]];static usage=$.Usage({category:"Contracts",description:"Replace an applied grant from the 1st of a month: the old one ends the day before, the new one takes its place."});grant=f.String({required:!0,name:"appliedGrantId"});from=f.String("--from",{required:!0,description:"First day of the new grant (YYYY-MM-01)"});async execute(){let n=await this.caller();return this.print(await n.mutation(x.contractGrants.replace,{client:this.requireTenant(n),appliedGrantId:this.grant,from:this.from,source:this.source(),eligibilityEvidence:this.parsedEvidence()})),0}},zk=class extends D{static{s(this,"ContractGrantAddAggregateCommand")}static paths=[["contract","grant","add-aggregate"]];static usage=$.Usage({category:"Contracts",description:"Apply a contract grant template to its eligible contract lines, with an optional agreed euro amount and floor."});contract=f.String("--contract",{required:!0,description:"contracts id"});template=f.String("--template",{required:!0,description:"Aggregate grant template configKey"});amount=f.String("--amount",{description:"Agreed euro deduction for the stated period"});floor=f.String("--floor",{description:"Agreed euro floor for the stated period"});period=f.String("--period",{description:"month|year|once|unit; changing period requires an explicit floor"});from=f.String("--from",{required:!0,description:"First day (YYYY-MM-01)"});to=f.String("--to",{description:"Last day (last day of a month)"});evidence=f.String("--evidence",{required:!0,description:"Finance decision and supporting evidence as a JSON object"});async execute(){let n=s(l=>{if(!/^(0|[1-9]\d*)(\.\d{1,2})?$/.test(l))throw new Error("Amounts must be nonnegative euros with at most two decimal places.");let d=Math.round(Number(l)*100);if(!Number.isSafeInteger(d))throw new Error("Amount is too large.");return d},"money");if(this.period!==void 0&&!ik.includes(this.period))throw new Error("--period must be month|year|once|unit.");let t;try{t=JSON.parse(this.evidence)}catch{throw new Error("--evidence must be a JSON object.")}if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("--evidence must be a JSON object.");let r=await this.caller(),i=this.requireTenant(r),a=(await r.query(x.contractConfig.model,{client:i})).grantTemplates.find(l=>l.configKey===this.template);if(!a||a.scope!=="aggregate")throw new Error("Name an existing aggregate grant template.");return this.print(await r.mutation(x.contractGrants.addAggregate,{client:i,contractId:this.contract,templateId:a.id,...this.amount===void 0?{}:{requestedAmountMinor:n(this.amount)},...this.floor===void 0?{}:{agreedFloorTotal:n(this.floor)},...this.period===void 0?{}:{pricePeriod:this.period},activeFrom:this.from,...this.to===void 0?{}:{activeTo:this.to},eligibilityEvidence:t})),0}},WD=[Vk,zk,Uk,Gk];import{readFileSync as W4,writeFileSync as Y4}from"node:fs";var Wk=[",",";"," "];function YD(e){let n=e.startsWith("\uFEFF")?e.slice(1):e;if(n.trim().length===0)throw new Error("The import file is empty.");let t=B4(n),r=V4(n,t),i=r[0];if(!i||i.cells.every(l=>l.trim().length===0))throw new Error("The import file needs a header row.");let o=U4(i.cells),a=r.slice(1).map(l=>{let d={};return o.forEach((c,u)=>{d[c]=l.cells[u]??""}),{rowNumber:l.lineNumber,values:d,cells:o.map((c,u)=>l.cells[u]??""),width:l.cells.length}});return{delimiter:t,columns:o,rows:a}}s(YD,"parseDelimitedText");function B4(e){let n=new Map(Wk.map(i=>[i,0])),t=!1;for(let i=0;i<e.length;i++){let o=e[i];if(o===void 0)break;if(o==='"'){if(t&&e[i+1]==='"'){i++;continue}t=!t;continue}if(!t&&(o===`
|
|
11214
|
+
`||o==="\r"))break;!t&&G4(o)&&n.set(o,(n.get(o)??0)+1)}return[...n.entries()].sort((i,o)=>{let a=o[1]-i[1];return a!==0?a:Wk.indexOf(i[0])-Wk.indexOf(o[0])})[0]?.[0]??","}s(B4,"detectDelimiter");function V4(e,n){let t=[],r=1,i=1,o="",a=[],l=!1,d=!1,c=!0;function u(){a.push(o),o="",c=!0,d=!1}s(u,"pushCell");function p(){u(),a.some(m=>m.length>0)&&t.push({lineNumber:i,cells:a}),a=[],i=r+1}s(p,"pushRecord");for(let m=0;m<e.length;m++){let y=e[m];if(l){if(y==='"'){e[m+1]==='"'?(o+='"',m++):(l=!1,d=!0);continue}if(y==="\r"){e[m+1]===`
|
|
11212
11215
|
`&&m++,o+=`
|
|
11213
11216
|
`,r++;continue}if(y===`
|
|
11214
11217
|
`){o+=`
|
|
11215
11218
|
`,r++;continue}o+=y;continue}if(d&&y!==n&&y!==`
|
|
11216
11219
|
`&&y!=="\r"){if(y===" "||y===" ")continue;throw new Error(`Malformed CSV near line ${r}: unexpected text after a quoted cell.`)}if(y===n){u();continue}if(y==="\r"){e[m+1]===`
|
|
11217
11220
|
`&&m++,p(),r++;continue}if(y===`
|
|
11218
|
-
`){p(),r++;continue}if(y==='"'){if(!c)throw new Error(`Malformed CSV near line ${r}: quote inside an unquoted cell.`);l=!0,c=!1;continue}o+=y,c=!1}if(l)throw new Error(`Malformed CSV near line ${r}: missing closing quote.`);return(o.length>0||a.length>0)&&p(),t}s(
|
|
11221
|
+
`){p(),r++;continue}if(y==='"'){if(!c)throw new Error(`Malformed CSV near line ${r}: quote inside an unquoted cell.`);l=!0,c=!1;continue}o+=y,c=!1}if(l)throw new Error(`Malformed CSV near line ${r}: missing closing quote.`);return(o.length>0||a.length>0)&&p(),t}s(V4,"parseRecords");function U4(e){let n=new Map;return e.map((t,r)=>{let i=t.trim()||`Column ${r+1}`,o=n.get(i)??0;return n.set(i,o+1),o===0?i:`${i} (${o+1})`})}s(U4,"uniqueColumnLabels");function G4(e){return e===","||e===";"||e===" "}s(G4,"isDelimiter");var JD=[{path:"/demo/videos",title:{de:"Videos",en:"Videos"}},{path:"/demo/school",title:{de:"Ihre Schule",en:"Your school"}},{path:"/demo/provider",title:{de:"Ihr Tr\xE4ger",en:"Your provider"}}],HD={"/demo/ihre-schule":"/demo/school","/demo/ihr-traeger":"/demo/provider"};function z4(e){let n=e.split(/[?#]/)[0].toLowerCase().replace(/\/+$/,""),t=Object.hasOwn(HD,n)?HD[n]:n;return JD.find(r=>r.path===t)?.path??null}s(z4,"demoPagePath");function QD(e){let n=JD.find(t=>t.path===z4(e));return n===void 0&&F(`demoPages: unknown page ${e}`),n.title}s(QD,"demoPageTitle");var H4=new Intl.DateTimeFormat("de-DE",{dateStyle:"short",timeStyle:"short",timeZone:"Europe/Berlin"});function Yk(e){return e==null?"\u2014":H4.format(new Date(e))}s(Yk,"when");function Jp(e){let n=Math.round(e);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}s(Jp,"mmss");var J4={name:"name",empf\u00E4nger:"name",empfaenger:"name",email:"email","e-mail":"email",mail:"email",video:"video","video-id":"video",videoid:"video"};function Q4(e,n){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{throw new Error(`demo link create: ${n} is not UTF-8 (umlauts would break). In Excel: Save as \u2192 \u201ECSV UTF-8 (durch Trennzeichen getrennt) (*.csv)".`)}}s(Q4,"decodeCsv");function Z4(e){let n=YD(e),t=new Map,r=[];for(let c of n.columns){let u=J4[c.trim().toLowerCase()];u===void 0?r.push(c):t.set(c,u)}if(r.length>0)throw new Error(`demo link create: unknown CSV column(s) ${r.map(c=>`"${c}"`).join(", ")} \u2014 use name, email (or E-Mail) and video.`);let i=s(c=>[...t].find(([,u])=>u===c)?.[0],"columnOf"),o=i("name");if(o===void 0)throw new Error(`demo link create: the CSV needs a "name" column (found: ${n.columns.join(", ")}).`);let a=i("email"),l=i("video"),d=n.rows.filter(c=>c.cells.some(u=>u.trim()!=="")).map(c=>{if(c.width===void 0)throw new Error("demo link create: the CSV parser reported no row width.");if(c.width>n.columns.length)throw new Error(`demo link create: row ${c.rowNumber} has more values than the header has columns \u2014 an unquoted comma in a name? Quote the value ("Winkler, Anne") or separate columns with ";".`);let u={name:c.values[o].trim()},p=a===void 0?"":c.values[a].trim(),m=l===void 0?"":c.values[l].trim();if(u.name==="")throw new Error(`demo link create: row ${c.rowNumber} has no name.`);return p!==""&&(u.email=p),m!==""&&(u.videoId=m),u});if(d.length===0)throw new Error("demo link create: the CSV holds no recipient.");return d}s(Z4,"recipientsFromCsv");function X4(e){return/[";\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}s(X4,"csvCell");function e6(e){let n=["name","email","video","campaign","code","url"],t=e.map(r=>[r.recipientName,r.recipientEmail??"",r.videoId??"",r.campaign??"",r.code,r.url].map(X4).join(";"));return"\uFEFF"+[n.join(";"),...t].join(`\r
|
|
11219
11222
|
`)+`\r
|
|
11220
|
-
`}s(
|
|
11223
|
+
`}s(e6,"linksCsv");function n6(e,n){if(e.to===void 0==(e.from===void 0))throw new Error("demo link create: give exactly one of --to <name> or --from <recipients.csv>.");if(e.from!==void 0){if(e.email!==void 0)throw new Error("demo link create: --email goes with --to, not --from.");return Z4(Q4(n(e.from),e.from))}return[{name:e.to,...e.email!==void 0?{email:e.email}:{}}]}s(n6,"recipientsOf");async function t6(e,n,t=r=>W4(r)){return await e.mutation(x.demoLinks.createLinks,{recipients:n6(n,t),...n.video!==void 0?{videoId:n.video}:{},...n.campaign!==void 0?{campaign:n.campaign}:{},...n.note!==void 0?{note:n.note}:{}})}s(t6,"createLinksRun");async function ZD(e,n){let{rows:t}=await Uu(e,x.demoLinks.listLinks,n===void 0?{}:{campaign:n},{pageSize:200});return t}s(ZD,"allLinks");function nb(e){return e.map(n=>({empf\u00E4nger:n.recipientName,email:n.recipientEmail??"\u2014",video:n.videoId??"(alle)",kampagne:n.campaign??"\u2014",url:n.url,...n.revokedAt!==void 0?{widerrufen:Yk(n.revokedAt)}:{}}))}s(nb,"linkRows");function r6(e){return e.pages.length===0?"\u2014":e.pages.map(n=>`${QD(n.path).de} ${Jp(n.activeSeconds)} (${n.views}\xD7)`).join(" \xB7 ")}s(r6,"pagesText");function i6(e){return e.flatMap(n=>{let t={empf\u00E4nger:n.recipientName,code:n.code,besuche:String(n.visits),erster:Yk(n.firstVisitAt),letzter:Yk(n.lastVisitAt),seiten:r6(n)};return n.videos.length===0?[{...t,video:n.videoId??"\u2014",gesehen:"\u2014","%":"\u2014"}]:n.videos.map(r=>({...t,video:r.videoId,gesehen:`${Jp(r.watchedSeconds)} / ${Jp(r.durationSeconds)}`,"%":`${r.percent} %`}))})}s(i6,"statsRows");var Hk=class extends D{static{s(this,"DemoVideosCommand")}static paths=[["demo","videos"]];static usage=$.Usage({category:"Marketing",description:"List the demo video catalogue (the ids a demo link can point at).",examples:[["List the videos","plexus-cli demo videos"]]});async execute(){let t=await(await this.caller()).query(x.demoLinks.listVideos,{});return this.print(t,r=>r.map(i=>({id:i.id,datum:i.date,titel:i.title.de,dauer:Jp(i.durationSeconds)})),["id","datum","titel","dauer"]),0}},Jk=class extends D{static{s(this,"DemoLinkCreateCommand")}static paths=[["demo","link","create"]];static usage=$.Usage({category:"Marketing",description:"Create personalised demo video links (one recipient, or a CSV). Needs _platform.demoLinks.manage.",details:`Each link belongs to one named recipient and, with --video, jumps to that video; without it the link opens the whole page. A visit counts once the page was visible for 5 s or the visitor interacted \u2014 a mail scanner that only fetches the link does not count. --from reads a UTF-8 CSV ("," or ";") with a header row: name, optional email (or E-Mail), optional video (a row's video wins over --video). The batch is created all or nothing. --out writes the links as a ";" CSV that German Excel opens directly.`,examples:[["One recipient, one video",'plexus-cli demo link create --to "Erika Mustermann" --video vorlagen --env prod --allow-prod'],["A CSV batch, result as CSV","plexus-cli demo link create --from recipients.csv --campaign herbst --out links.csv --env prod --allow-prod"]]});to=f.String("--to",{description:"The recipient's name."});email=f.String("--email",{description:"The recipient's email address (with --to)."});from=f.String("--from",{description:"UTF-8 CSV of recipients: name, email, video."});video=f.String("--video",{description:"Video id (see `demo videos`); without it the whole page."});campaign=f.String("--campaign",{description:"Campaign label, to list and count links together."});note=f.String("--note",{description:"Free note kept with the links."});out=f.String("--out",{description:"Also write the created links as CSV to this file (refused when it exists, unless --force)."});force=kn();async execute(){let n=this.out===void 0?void 0:_n(this.out,this.force),t=await this.caller(),r=await t6(t,{to:this.to,email:this.email,from:this.from,video:this.video,campaign:this.campaign,note:this.note});return this.print(r,nb,["empf\xE4nger","email","video","kampagne","url"]),n!==void 0&&Y4(n,e6(r)),0}},Qk=class extends D{static{s(this,"DemoLinkListCommand")}static paths=[["demo","link","list"]];static usage=$.Usage({category:"Marketing",description:"List demo links, newest first. Needs _platform.demoLinks.manage."});campaign=f.String("--campaign",{description:"Only this campaign."});async execute(){let n=await this.caller();return this.print(await ZD(n,this.campaign),nb,["empf\xE4nger","email","video","kampagne","url","widerrufen"]),0}},Zk=class extends D{static{s(this,"DemoLinkStatsCommand")}static paths=[["demo","link","stats"]];static usage=$.Usage({category:"Marketing",description:"Who opened their demo link, when, how often, how long per video and per demo page. Needs _platform.demoLinks.manage.",details:"besuche = page loads a person engaged with (visible 5 s or an interaction); erster/letzter = first and latest visit (Europe/Berlin); gesehen = seconds actually played, summed over visits, / video length; % = how much of the video the best single visit actually played (skipping ahead does not count); seiten = per demo page the time it was visible, summed over visits (mm:ss), and how many visits viewed it \u2014 a page counts after 5 s visible or an interaction there.",examples:[["One link","plexus-cli demo link stats k7m2q9xdp3ab --env prod"],["A campaign","plexus-cli demo link stats --campaign herbst --env prod"]]});code=f.String({required:!1,name:"code"});campaign=f.String("--campaign",{description:"Only this campaign (not together with a code)."});async execute(){if(this.code!==void 0&&this.campaign!==void 0)throw new Error("demo link stats: either a code or --campaign, not both.");let n=await this.caller(),t=this.code===void 0?await ZD(n,this.campaign):[await n.query(x.demoLinks.getLink,{code:this.code})];return this.print(t,i6,["empf\xE4nger","code","video","besuche","erster","letzter","seiten","gesehen","%"]),0}},Xk=class extends D{static{s(this,"DemoLinkRevokeCommand")}static paths=[["demo","link","revoke"]];static usage=$.Usage({category:"Marketing",description:"Stop recording for a demo link \u2014 plan unless --confirm; the page keeps working and its statistics stay. Needs _platform.demoLinks.manage."});code=f.String({required:!0,name:"code"});confirm=f.Boolean("--confirm",!1,{description:"Revoke (without it, only the plan is printed)."});async execute(){let n=await this.caller();if(!this.confirm){let r=await n.query(x.demoLinks.getLink,{code:this.code});return this.context.stdout.write(`Would stop recording for the link of ${r.recipientName} (${r.code}). Re-run with --confirm.
|
|
11221
11224
|
`),0}let t=await n.mutation(x.demoLinks.revokeLink,{code:this.code});return this.print([t],nb,["empf\xE4nger","video","url","widerrufen"]),0}},eb=class extends D{static{s(this,"DemoLinkDeleteCommand")}static paths=[["demo","link","delete"]];static usage=$.Usage({category:"Marketing",description:"Erase a demo link: the recipient's name and address and everything recorded for it. Needs _platform.demoLinks.manage.",details:"Without --confirm it only shows what would be deleted. The deletion cannot be undone; the page keeps working for anyone who still has the link, and records nothing.",examples:[["Erase on request","plexus-cli demo link delete k7m2q9xdp3ab --confirm --env prod --allow-prod"]]});code=f.String({required:!0,name:"code"});confirm=f.Boolean("--confirm",!1,{description:"Really delete."});async execute(){let n=await this.caller();if(!this.confirm){let r=await n.query(x.demoLinks.getLink,{code:this.code});return this.context.stdout.write(`Would delete the link of ${r.recipientName} (${r.code}) with ${r.visits} visit(s). Re-run with --confirm.
|
|
11222
|
-
`),0}let t=await n.mutation(x.demoLinks.deleteLink,{code:this.code});return this.print(t,r=>[{gel\u00F6scht:r.code,empf\u00E4nger:r.recipientName}]),0}},XD=[Hk,Jk,Qk,Zk,Xk,eb];var qo=["offen","todo","bearbeitung","klaerung","abgeschlossen","spaeter"],
|
|
11225
|
+
`),0}let t=await n.mutation(x.demoLinks.deleteLink,{code:this.code});return this.print(t,r=>[{gel\u00F6scht:r.code,empf\u00E4nger:r.recipientName}]),0}},XD=[Hk,Jk,Qk,Zk,Xk,eb];var qo=["offen","todo","bearbeitung","klaerung","abgeschlossen","spaeter"],o6=w.union(w.literal("offen"),w.literal("todo"),w.literal("bearbeitung"),w.literal("klaerung"),w.literal("abgeschlossen"),w.literal("spaeter")),s6=o6,a6=w.union(w.literal("open"),w.literal("closed")),l6=w.union(w.literal("completed"),w.literal("not_planned"),w.literal("reopened"),w.literal("duplicate"),w.null()),d6=w.object({repo:w.string(),number:w.number(),url:w.string(),state:a6,stateReason:w.optional(l6),linkedAt:w.number(),lastSyncedAt:w.number()}),c6=w.object({pathname:w.string(),search:w.string(),hash:w.string(),pageTitle:w.string(),selectedUnit:w.optional(w.object({id:w.string(),unitId:w.optional(Yn.history(w.id("units"))),label:w.string(),kind:w.union(w.literal("tenant"),w.literal("unit"))})),viewport:w.object({width:w.number(),height:w.number(),devicePixelRatio:w.number()}),locale:w.string(),timezone:w.string()}),u6={tenantId:Yn.tenant(w.id("tenants")),userId:Yn.history(w.id("users")),summary:w.string(),situation:w.optional(w.string()),goal:w.optional(w.string()),needToSee:w.optional(w.string()),needToDo:w.optional(w.string()),reason:w.optional(w.string()),currentWorkaround:w.optional(w.string()),status:s6,boardRank:w.number(),context:c6,screenshotStorageId:w.optional(Yn.owns(w.id("_storage"))),githubIssue:w.optional(d6),githubIssueKey:w.optional(w.string()),deadline:w.optional(w.number()),assigneeUserId:w.optional(Yn.restrict(w.id("users"),{unindexed:"only by_status_and_assignee, which leads with status"})),lastActivityAt:w.number(),openReplaySessionURL:w.optional(w.string())},xAe=Jr(u6).index("by_tenantId",["tenantId"]).index("by_tenantId_and_userId",["tenantId","userId"]).index("by_tenantId_and_status",["tenantId","status"]).index("by_github_issue",["githubIssueKey"]).index("by_status_and_rank",["status","boardRank"]).index("by_tenantId_and_status_and_rank",["tenantId","status","boardRank"]).index("by_tenantId_and_userId_and_status",["tenantId","userId","status"]).index("by_status_and_deadline",["status","deadline"]).index("by_status_and_assignee",["status","assigneeUserId"]).index("by_screenshotStorageId",["screenshotStorageId"]);import*as Qp from"node:child_process";function eF(e){return new Proxy(e,{apply(n,t,r){if(dn())throw new Error("plexus: this command requires a local machine and cannot run in a platform chat.");return Reflect.apply(n,t,r)}})}s(eF,"localOnly");var nF=eF(Qp.spawnSync),tb=eF(Qp.execFileSync);var rb="SmartKomm/plexus",rF="feedback",Zp=["bug","feature","task"],f6={bug:"d73a4a",feature:"0e8a16",task:"1d76db"};function Xp(e){return Math.trunc(e.number)}s(Xp,"issueNumber");function iF(...e){try{return tb("gh",e,{encoding:"utf8"}).trim()}catch(n){throw new Error(`gh ${e.join(" ")} failed: ${kt(n)}`,{cause:n})}}s(iF,"gh");function ib(e){try{return{ok:!0,stdout:tb("gh",e,{encoding:"utf8"}),stderr:""}}catch(n){let t=n;return{ok:!1,stdout:t.stdout?.toString()??"",stderr:t.stderr?.toString()??""}}}s(ib,"ghRaw");function oF(e,n){let t=(e||"").toUpperCase()==="CLOSED"?"closed":"open",r={COMPLETED:"completed",NOT_PLANNED:"not_planned",REOPENED:"reopened"}[(n||"").toUpperCase()];return{state:t,reason:r}}s(oF,"mapGhState");async function sF(e){try{let n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status} ${n.statusText}`);return{bytes:new Uint8Array(await n.arrayBuffer()),contentType:n.headers.get("content-type")}}catch(n){throw new Error(`Could not download feedback screenshot: ${kt(n)}`,{cause:n})}}s(sF,"downloadScreenshot");function aF(e,n,t){let{screenshotUrl:r,noScreenshot:i}=t;if(r!==void 0&&i)throw new Error("Pass either --screenshot-url or --no-screenshot, not both.");if(!n){if(r!==void 0)throw new Error(`Feedback ${e} has no screenshot \u2014 drop --screenshot-url.`);return null}if(i)return null;if(r===void 0)throw new Error(`Feedback ${e} has a screenshot. Save it with \`plexus-cli feedback screenshot ${e} --out <file>\`, upload it with your environment's upload tool as an EXPIRING (presigned) link \u2014 feedback screenshots can show customer data \u2014 and pass --screenshot-url <url>. Or file without it: --no-screenshot.`);let o;try{o=new URL(r)}catch{throw new Error(`--screenshot-url is not a URL: ${JSON.stringify(r)}`)}if(o.protocol!=="https:")throw new Error(`--screenshot-url must be https: ${JSON.stringify(r)}`);return o.href}s(aF,"screenshotForIssue");function lF(e){let n=new URL(e),t=n.hostname.split("."),r=t.indexOf("db");if(r===-1)throw new Error(`Cannot derive the app URL from convexUrl ${JSON.stringify(e)} (expected a 'db.' host label).`);return t.splice(r,1),`${n.protocol}//${t.join(".")}`}s(lF,"appBaseUrl");function dF(e,n,t){return`${e}/${n}/feedback?item=${encodeURIComponent(t)}`}s(dF,"feedbackItemUrl");function p6(e){let n=(e.name??"").trim(),t=(e.email??"").trim();return n&&t&&n!==t?`${n} (${t})`:t||n}s(p6,"reportedBy");function tF(e){return(e||"").split(`
|
|
11223
11226
|
`).map(n=>`> ${n}`).join(`
|
|
11224
|
-
`)}s(tF,"blockquote");function cF(e,n){let t=`type:${n}`;return ib(["label","create",t,"--repo",e,"--force","--color",
|
|
11225
|
-
`)}s(fF,"issueBody");function Zl(e){if(/^\d+$/.test(e))return Number.parseInt(e,10);let n=Date.parse(e);if(Number.isNaN(n))throw new Error(`Invalid date ${JSON.stringify(e)} \u2014 use ISO (e.g. 2026-06-20) or epoch ms.`);return n}s(Zl,"parseDateMs");async function em(e,n){if(n==="@me"||n==="me")return(await e.query(x.platformFeedback.whoAmI,{})).userId;if(!n.includes("@"))return n;let r=(await e.query(x.platformFeedback.listPlatformAdmins,{})).find(i=>i.email.toLowerCase()===n.toLowerCase());if(r===void 0)throw new Error(`No platform admin with email ${JSON.stringify(n)}.`);return r.userId}s(em,"resolveAssigneeUserId");var Xl=class extends D{static{s(this,"FeedbackListCommand")}static paths=[["feedback","list"]];static usage=$.Usage({category:"Feedback",description:"List feedback (active tenant, or --all-tenants for a platform admin)."});limit=f.String("--limit",{description:"Max rows (default 50)."});fetchAll=f.Boolean("--all",!1,{description:"Fetch every page."});allTenants=f.Boolean("--all-tenants",!1,{description:"Cross-tenant platform view (requires _platform.feedback.read)."});status=f.String("--status",{description:`Filter by status (${qo.join("|")}).`});withIssues=f.Boolean("--with-issues",!1,{description:"Only items linked to a GitHub issue."});withoutIssues=f.Boolean("--without-issues",!1,{description:"Only items NOT yet linked to a GitHub issue."});text=f.String("--text",{description:"Filter: summary or submitter name/email contains this text."});tagIds=f.Array("--tag",{description:"Filter: item carries any of these tag ids (repeatable)."});assignee=f.String("--assignee",{description:"Filter: assignee @me, userId, or email (platform; needs --all-tenants)."});deadlineFrom=f.String("--deadline-from",{description:"Filter: deadline >= ISO/epoch (platform; needs --all-tenants)."});deadlineTo=f.String("--deadline-to",{description:"Filter: deadline <= ISO/epoch (platform; needs --all-tenants)."});async execute(){let n=await this.caller(),t=this.limit===void 0?50:Number.parseInt(this.limit,10);if(Number.isNaN(t))throw new Error(`feedback list: --limit must be an integer, got "${this.limit}".`);let r=this.fetchAll?void 0:t,i=this.assignee||this.deadlineFrom||this.deadlineTo;if(!this.allTenants){if(this.withIssues||this.withoutIssues||i)throw new Error("--with-issues/--without-issues/--assignee/--deadline-* require --all-tenants (the GitHub link, assignee and deadline are platform-admin-only).");let d=this.requireTenant(n),c=await this.paginate(n,x.feedback.listTenant,{client:d},{max:r});return c=this.applyTextTagFilter(c),this.print(c),0}let o=this.parseStatus(),a={};o!==void 0&&(a.status=o),this.text!==void 0&&(a.text=this.text),this.tagIds&&this.tagIds.length>0&&(a.tagIds=this.tagIds),this.assignee!==void 0&&(a.assigneeUserId=await em(n,this.assignee)),this.deadlineFrom!==void 0&&(a.deadlineFrom=Zl(this.deadlineFrom)),this.deadlineTo!==void 0&&(a.deadlineTo=Zl(this.deadlineTo));let l=await this.paginate(n,x.platformFeedback.listAllPlatform,a,{max:r});return this.withIssues&&(l=l.filter(d=>d.githubIssue)),this.withoutIssues&&(l=l.filter(d=>!d.githubIssue)),this.print(l,d=>d.map(m4),["id","tenant","status","tags","summary","issue","resolved"]),0}applyTextTagFilter(n){let t=this.text?.trim().toLowerCase(),r=this.tagIds&&this.tagIds.length>0?new Set(this.tagIds):null;return n.filter(i=>!(t&&!`${i.summary??""} ${i.submittedBy?.name??""} ${i.submittedBy?.email??""}`.toLowerCase().includes(t)||r&&!(i.tags??[]).some(o=>r.has(o.id))))}parseStatus(){if(this.status!==void 0){if(!qo.includes(this.status))throw new Error(`feedback list: --status must be one of ${qo.join("|")}.`);return this.status}}};function m4(e){let n=e.githubIssue;return{id:e.id,tenant:e.tenantSlug,status:e.status,tags:(e.tags??[]).map(t=>t.name).join(", "),summary:(e.summary??"").slice(0,50),issue:n?`#${Xp(n)} (${n.state})`:"",resolved:e.resolved?"\u2713":""}}s(m4,"platformRow");var ed=class extends D{static{s(this,"FeedbackToIssueCommand")}static paths=[["feedback","to-issue"]];static usage=$.Usage({category:"Feedback",description:"Create + link a GitHub issue for a feedback item (idempotent)."});feedbackId=f.String({required:!0,name:"feedbackId"});repo=f.String("--repo",rb,{description:`Default ${rb}.`});issueType=f.String("--type",{description:`Triage type (${Zp.join("|")}) \u2014 added as a 'type:<t>' label.`});dryRun=f.Boolean("--dry-run",!1,{description:"Render the issue without creating it."});screenshotUrl=f.String("--screenshot-url",{description:"Hosted (expiring) link to the item's screenshot \u2014 required when the item has one. Save it with `feedback screenshot <id> --out <file>` first."});noScreenshot=f.Boolean("--no-screenshot",!1,{description:"File an item that has a screenshot without it."});async execute(){let n=await this.caller(),t=this.feedbackId,r=await n.query(x.platformFeedback.getById,{feedbackItemId:t}),i=r.githubIssue;if(i&&!this.dryRun)return this.print({feedbackId:this.feedbackId,issue:i.url,alreadyLinked:!0},g=>[{field:"feedbackId",value:g.feedbackId},{field:"issue",value:g.issue},{field:"alreadyLinked",value:"\u2713"}]),0;if(this.issueType!==void 0&&!Zp.includes(this.issueType))throw new Error(`Invalid --type ${JSON.stringify(this.issueType)} \u2014 expected one of ${Zp.join("|")}.`);let o=this.issueType,a=uF(r),l=dF(lF(n.convexUrl),r.tenantSlug,this.feedbackId),d=[rF,...o?[`type:${o}`]:[]],c=aF(this.feedbackId,!!r.screenshotUrl,{screenshotUrl:this.screenshotUrl,noScreenshot:this.noScreenshot}),u=fF(r,c,l);if(this.dryRun)return this.print({repo:this.repo,title:a,labels:d,hasScreenshot:!!r.screenshotUrl,screenshotUrl:c,body:u}),0;o&&cF(this.repo,o);let p=d.flatMap(g=>["--label",g]),m=iF("issue","create","--repo",this.repo,"--title",a,...p,"--body",u);if(!m.startsWith("https://github.com/"))throw new Error(`Unexpected gh output (not an issue URL): ${JSON.stringify(m)}`);let y=Number.parseInt(m.replace(/\/+$/,"").split("/").pop()??"",10);if(Number.isNaN(y))throw new Error(`Could not parse issue number from gh output: ${JSON.stringify(m)}`);let k=await n.mutation(x.platformFeedback.attachGithubIssue,{feedbackItemId:t,repo:this.repo,number:y,url:m,state:"open"});return this.print({feedbackId:this.feedbackId,issue:m,link:k},g=>[{field:"feedbackId",value:g.feedbackId},{field:"issue",value:g.issue}]),0}},nd=class extends D{static{s(this,"FeedbackSyncCommand")}static paths=[["feedback","sync"]];static usage=$.Usage({category:"Feedback",description:"Fetch GitHub issue state onto linked feedback (issue closed \u21D2 resolved)."});allTenants=f.Boolean("--all-tenants",!1);async execute(){let n=await this.caller();if(!this.allTenants)throw new Error("feedback sync requires --all-tenants (the GitHub link is platform-admin-only).");let r=(await this.paginate(n,x.platformFeedback.listAllPlatform,{})).filter(o=>o.githubIssue),i=[];for(let o of r){let a=o.githubIssue;if(!a)continue;let l=Xp(a),d=`${a.repo}#${l}`,c=ib(["issue","view",String(l),"--repo",a.repo,"--json","state,stateReason"]);if(!c.ok){i.push({id:o.id,issue:d,state:"error",resolved:""});continue}let u;try{u=JSON.parse(c.stdout)}catch{i.push({id:o.id,issue:d,state:"error",resolved:""});continue}let{state:p,reason:m}=oF(u.state??"",u.stateReason??"");await n.mutation(x.platformFeedback.syncGithubIssueState,{feedbackItemId:o.id,state:p,...m!==void 0?{stateReason:m}:{}}),i.push({id:o.id,issue:d,state:p,resolved:p==="closed"?"\u2713":""})}return this.print(i,o=>o.map(a=>({...a})),["id","issue","state","resolved"]),0}};var td=class extends D{static{s(this,"FeedbackSetStatusCommand")}static paths=[["feedback","set-status"]];static usage=$.Usage({category:"Feedback",description:"Manually move a feedback item to a board status."});feedbackId=f.String({required:!0,name:"feedbackId"});status=f.String({required:!0,name:"status"});async execute(){let n=await this.caller();if(!qo.includes(this.status))throw new Error(`feedback set-status: status must be one of ${qo.join("|")}.`);return await n.mutation(x.platformFeedback.setFeedbackStatus,{feedbackItemId:this.feedbackId,status:this.status}),this.print({feedbackId:this.feedbackId,status:this.status},t=>[{field:"feedbackId",value:t.feedbackId},{field:"status",value:t.status}]),0}},rd=class extends D{static{s(this,"FeedbackReassignCommand")}static paths=[["feedback","reassign"]];static usage=$.Usage({category:"Feedback",description:"Move a feedback item to another tenant (by target tenant slug)."});feedbackId=f.String({required:!0,name:"feedbackId"});tenantSlug=f.String({required:!0,name:"tenantSlug"});async execute(){let n=await this.caller(),t=await n.query(x.platformFeedback.listAllTenantsForAssignment,{}),r=t.find(i=>i.slug===this.tenantSlug);if(r===void 0){let i=t.map(o=>o.slug).join(", ");throw new Error(`feedback reassign: no tenant "${this.tenantSlug}". Available: ${i||"(none)"}.`)}return await n.mutation(x.platformFeedback.reassignTenant,{feedbackItemId:this.feedbackId,newTenantId:r.id}),this.print({feedbackId:this.feedbackId,tenantSlug:this.tenantSlug},i=>[{field:"feedbackId",value:i.feedbackId},{field:"tenantSlug",value:i.tenantSlug}]),0}},id=class extends D{static{s(this,"FeedbackReplyCommand")}static paths=[["feedback","reply"]];static usage=$.Usage({category:"Feedback",description:"Post a platform reply on a feedback item (public by default; --internal for a platform-only note)."});feedbackId=f.String({required:!0,name:"feedbackId"});body=f.String({required:!0,name:"body"});internal=f.Boolean("--internal",!1,{description:"Post as an internal note (not visible to the tenant)."});async execute(){let t=await(await this.caller()).mutation(x.platformFeedback.addComment,{feedbackItemId:this.feedbackId,body:this.body,visibility:this.internal?"internal":"public"});return this.print(t,r=>[{field:"id",value:r.id},{field:"visibility",value:r.visibility},{field:"author",value:r.authorName}]),0}},od=class extends D{static{s(this,"FeedbackCommentsCommand")}static paths=[["feedback","comments"]];static usage=$.Usage({category:"Feedback",description:"List the conversation (public replies + internal notes) on a feedback item."});feedbackId=f.String({required:!0,name:"feedbackId"});async execute(){let t=await(await this.caller()).query(x.platformFeedback.listComments,{feedbackItemId:this.feedbackId});return this.print(t,r=>r.map(i=>({id:i.id,visibility:i.visibility,author:i.authorName,body:i.body})),["id","visibility","author","body"]),0}},sd=class extends D{static{s(this,"FeedbackDeadlineCommand")}static paths=[["feedback","set-deadline"],["feedback","deadline"]];static usage=$.Usage({category:"Feedback",description:"Set or clear a feedback item's deadline (platform admin)."});feedbackId=f.String({required:!0,name:"feedbackId"});date=f.String({required:!1,name:"date"});clear=f.Boolean("--clear",!1,{description:"Clear the deadline."});async execute(){let n=await this.caller();if(!this.clear&&this.date===void 0)throw new Error("feedback deadline: pass a date (ISO/epoch) or --clear.");let t=this.clear?null:Zl(this.date);return await n.mutation(x.platformFeedback.setDeadline,{feedbackItemId:this.feedbackId,deadline:t}),this.print({feedbackId:this.feedbackId,deadline:t===null?"(cleared)":new Date(t).toISOString()},r=>[{field:"feedbackId",value:r.feedbackId},{field:"deadline",value:r.deadline}]),0}},ad=class extends D{static{s(this,"FeedbackAdminsCommand")}static paths=[["feedback","admins"]];static usage=$.Usage({category:"Feedback",description:"List platform admins (valid feedback assignees)."});async execute(){let t=await(await this.caller()).query(x.platformFeedback.listPlatformAdmins,{});return this.print(t,r=>r.map(i=>({userId:i.userId,name:i.name,email:i.email})),["userId","name","email"]),0}},ld=class extends D{static{s(this,"FeedbackAssignCommand")}static paths=[["feedback","assign"]];static usage=$.Usage({category:"Feedback",description:"Assign a feedback item to a platform admin (userId or email), or --clear."});feedbackId=f.String({required:!0,name:"feedbackId"});assignee=f.String({required:!1,name:"assignee"});clear=f.Boolean("--clear",!1,{description:"Unassign."});async execute(){let n=await this.caller();if(!this.clear&&this.assignee===void 0)throw new Error("feedback assign: pass a userId/email or --clear.");let t=this.clear?null:await em(n,this.assignee);return await n.mutation(x.platformFeedback.assign,{feedbackItemId:this.feedbackId,assigneeUserId:t}),this.print({feedbackId:this.feedbackId,assignee:t??"(cleared)"},r=>[{field:"feedbackId",value:r.feedbackId},{field:"assignee",value:r.assignee}]),0}};function wd(e){return[{field:"id",value:e.id},{field:"name",value:e.name},{field:"color",value:e.color},{field:"scope",value:e.scope}]}s(wd,"tagRows");function ob(e){if(e==="public"||e==="platform")return e;throw new Error(`Invalid visibility "${e}" \u2014 expected "public" or "platform".`)}s(ob,"parseTagScope");var dd=class extends D{static{s(this,"FeedbackTagsListCommand")}static paths=[["feedback","tags","list"]];static usage=$.Usage({category:"Feedback",description:"List the global feedback tag catalog (incl. platform-only tags)."});async execute(){let t=await(await this.caller()).query(x.feedbackTags.listAllTags,{});return this.print(t,r=>r.map(i=>({id:i.id,name:i.name,color:i.color,scope:i.scope})),["id","name","color","scope"]),0}},cd=class extends D{static{s(this,"FeedbackTagsCreateCommand")}static paths=[["feedback","tags","create"]];static usage=$.Usage({category:"Feedback",description:"Create a tag (platform admin). --color is a 6-hex code, e.g. d73a4a; --visibility is public (default) or platform."});name=f.String({required:!0,name:"name"});color=f.String("--color",{required:!0,description:"6-hex colour (no '#')."});visibility=f.String("--visibility",{description:"public (default) or platform (platform-admins only)."});async execute(){let t=await(await this.caller()).mutation(x.feedbackTags.createTag,{name:this.name,color:this.color,scope:this.visibility?ob(this.visibility):"public"});return this.print(t,wd),0}},ud=class extends D{static{s(this,"FeedbackTagsSetCommand")}static paths=[["feedback","tags","set"]];static usage=$.Usage({category:"Feedback",description:"Change a tag's name, colour and/or visibility (platform admin).",examples:[["Rename and recolour","$0 --env staging feedback tags set <tagId> --name Bug --color d73a4a"]]});tagId=f.String({required:!0,name:"tagId"});name=f.String("--name",{description:"New name."});color=f.String("--color",{description:"New 6-hex colour (no '#')."});visibility=f.String("--visibility",{description:"public (everyone) or platform (platform-admins only)."});async execute(){if(this.name===void 0&&this.color===void 0&&this.visibility===void 0)throw new Error("feedback tags set: pass at least one of --name, --color, --visibility.");let n=this.visibility===void 0?void 0:ob(this.visibility),t=await this.caller(),r=this.tagId,i,o=[];try{this.name!==void 0&&(i=await t.mutation(x.feedbackTags.renameTag,{tagId:r,name:this.name}),o.push("--name")),this.color!==void 0&&(i=await t.mutation(x.feedbackTags.recolorTag,{tagId:r,color:this.color}),o.push("--color")),n!==void 0&&(i=await t.mutation(x.feedbackTags.setTagVisibility,{tagId:r,scope:n}),o.push("--visibility"))}catch(a){throw o.length>0&&this.context.stderr.write(`feedback tags set: ${o.join(", ")} already applied.
|
|
11226
|
-
`),a}if(i===void 0)throw new Error("feedback tags set: no change was sent.");return this.print(i,wd),0}},fd=class extends D{static{s(this,"FeedbackTagsVisibilityCommand")}static paths=[["feedback","tags","visibility"]];tagId=f.String({required:!0,name:"tagId"});scope=f.String({required:!0,name:"scope"});async execute(){an(this.context.stderr,"feedback tags visibility","feedback tags set <tagId> --visibility <scope>");let t=await(await this.caller()).mutation(x.feedbackTags.setTagVisibility,{tagId:this.tagId,scope:ob(this.scope)});return this.print(t,wd),0}},pd=class extends D{static{s(this,"FeedbackTagsRenameCommand")}static paths=[["feedback","tags","rename"]];tagId=f.String({required:!0,name:"tagId"});name=f.String({required:!0,name:"name"});async execute(){an(this.context.stderr,"feedback tags rename","feedback tags set <tagId> --name <name>");let t=await(await this.caller()).mutation(x.feedbackTags.renameTag,{tagId:this.tagId,name:this.name});return this.print(t,wd),0}},md=class extends D{static{s(this,"FeedbackTagsRecolorCommand")}static paths=[["feedback","tags","recolor"]];tagId=f.String({required:!0,name:"tagId"});color=f.String({required:!0,name:"color"});async execute(){an(this.context.stderr,"feedback tags recolor","feedback tags set <tagId> --color <hex>");let t=await(await this.caller()).mutation(x.feedbackTags.recolorTag,{tagId:this.tagId,color:this.color});return this.print(t,wd),0}},hd=class extends D{static{s(this,"FeedbackTagsDeleteCommand")}static paths=[["feedback","tags","delete"]];static usage=$.Usage({category:"Feedback",description:"Delete a tag and detach it from all items (platform admin) \u2014 plan unless --confirm."});tagId=f.String({required:!0,name:"tagId"});confirm=f.Boolean("--confirm",!1,{description:"Delete (without it, only the plan is printed)."});async execute(){let n=await this.caller();if(!this.confirm){let t=(await n.query(x.feedbackTags.listAllTags,{})).find(r=>r.id===this.tagId);if(t===void 0)throw new Error(`No feedback tag ${this.tagId} \u2014 see \`feedback tags list\`.`);return this.print({tagId:t.id,name:t.name,deleted:!1},r=>[{field:"would delete",value:`${r.name} (${r.tagId}) \u2014 detached from every item`},{field:"next",value:"re-run with --confirm"}]),0}return await n.mutation(x.feedbackTags.deleteTag,{tagId:this.tagId}),this.print({tagId:this.tagId,deleted:!0},t=>[{field:"tagId",value:t.tagId},{field:"deleted",value:"\u2713"}]),0}},gd=class extends D{static{s(this,"FeedbackTagAttachCommand")}static paths=[["feedback","tag"]];static usage=$.Usage({category:"Feedback",description:"Attach an existing tag to a feedback item (uses the active --tenant)."});feedbackId=f.String({required:!0,name:"feedbackId"});tagId=f.String({required:!0,name:"tagId"});async execute(){let n=await this.caller(),t=this.requireTenant(n);return await n.mutation(x.feedbackTags.attachTag,{client:t,feedbackItemId:this.feedbackId,tagId:this.tagId}),this.print({feedbackId:this.feedbackId,tagId:this.tagId,attached:!0},r=>[{field:"feedbackId",value:r.feedbackId},{field:"tagId",value:r.tagId},{field:"attached",value:"\u2713"}]),0}},yd=class extends D{static{s(this,"FeedbackUntagCommand")}static paths=[["feedback","untag"]];static usage=$.Usage({category:"Feedback",description:"Detach a tag from a feedback item (uses the active --tenant)."});feedbackId=f.String({required:!0,name:"feedbackId"});tagId=f.String({required:!0,name:"tagId"});async execute(){let n=await this.caller(),t=this.requireTenant(n);return await n.mutation(x.feedbackTags.detachTag,{client:t,feedbackItemId:this.feedbackId,tagId:this.tagId}),this.print({feedbackId:this.feedbackId,tagId:this.tagId,detached:!0},r=>[{field:"feedbackId",value:r.feedbackId},{field:"tagId",value:r.tagId},{field:"detached",value:"\u2713"}]),0}};var kd=class extends D{static{s(this,"FeedbackLinkCommand")}static paths=[["feedback","link"]];static usage=$.Usage({category:"Feedback",description:"Link two feedback items together (platform admin)."});feedbackId=f.String({required:!0,name:"feedbackId"});otherId=f.String({required:!0,name:"otherFeedbackId"});async execute(){return await(await this.caller()).mutation(x.platformFeedback.linkItems,{feedbackItemId:this.feedbackId,otherFeedbackItemId:this.otherId}),this.print({a:this.feedbackId,b:this.otherId,linked:!0},t=>[{field:"feedbackId",value:t.a},{field:"linkedTo",value:t.b},{field:"linked",value:"\u2713"}]),0}},bd=class extends D{static{s(this,"FeedbackUnlinkCommand")}static paths=[["feedback","unlink"]];static usage=$.Usage({category:"Feedback",description:"Remove a link between two feedback items (platform admin)."});feedbackId=f.String({required:!0,name:"feedbackId"});otherId=f.String({required:!0,name:"otherFeedbackId"});async execute(){return await(await this.caller()).mutation(x.platformFeedback.unlinkItems,{feedbackItemId:this.feedbackId,otherFeedbackItemId:this.otherId}),this.print({a:this.feedbackId,b:this.otherId,unlinked:!0},t=>[{field:"feedbackId",value:t.a},{field:"unlinkedFrom",value:t.b},{field:"unlinked",value:"\u2713"}]),0}},vd=class extends D{static{s(this,"FeedbackLinksCommand")}static paths=[["feedback","links"]];static usage=$.Usage({category:"Feedback",description:"List the feedback items linked to a given item (platform admin)."});feedbackId=f.String({required:!0,name:"feedbackId"});async execute(){let t=await(await this.caller()).query(x.platformFeedback.listLinks,{feedbackItemId:this.feedbackId});return this.print(t,r=>r.map(i=>({id:i.id,status:i.status,tenant:i.tenantSlug,summary:i.summary})),["id","status","tenant","summary"]),0}};var xd=class extends D{static{s(this,"FeedbackCreateCommand")}static paths=[["feedback","create"]];static usage=$.Usage({category:"Feedback",description:"File platform-level feedback (tenant-less, no screenshot). Needs _platform.feedback.read."});summary=f.String("--summary",{required:!0,description:"Short one-line summary (required)."});tag=f.Array("--tag",{description:"Catalog tag id to attach (repeatable). Platform admins may attach internal tags."});situation=f.String("--situation",{description:"What happened."});goal=f.String("--goal",{description:"What you were trying to do."});needToSee=f.String("--need-to-see",{description:"What you expected to see."});needToDo=f.String("--need-to-do",{description:"What you needed to do."});reason=f.String("--reason",{description:"Why it matters."});workaround=f.String("--workaround",{description:"Current workaround, if any."});async execute(){if(this.summary.trim().length===0)throw new Error("feedback create: --summary must not be empty.");let n=this.tag??[],r=await(await this.caller()).mutation(x.platformFeedback.createPlatformFeedback,{summary:this.summary,...n.length>0?{tagIds:n}:{},...this.situation!==void 0?{situation:this.situation}:{},...this.goal!==void 0?{goal:this.goal}:{},...this.needToSee!==void 0?{needToSee:this.needToSee}:{},...this.needToDo!==void 0?{needToDo:this.needToDo}:{},...this.reason!==void 0?{reason:this.reason}:{},...this.workaround!==void 0?{currentWorkaround:this.workaround}:{},context:{pathname:"/cli",search:"",hash:"",pageTitle:"plexus-cli feedback create",viewport:{width:0,height:0,devicePixelRatio:1},locale:"de",timezone:"UTC"}});return this.print({feedbackId:r.feedbackId,tags:n.join(", "),summary:this.summary},i=>[{field:"feedbackId",value:i.feedbackId},{field:"tags",value:i.tags},{field:"summary",value:i.summary}]),0}};var Sd=class extends D{static{s(this,"FeedbackScreenshotCommand")}static paths=[["feedback","screenshot"]];static usage=$.Usage({category:"Feedback",description:"Save a feedback item's screenshot to a local file.",details:"Feedback screenshots can show customer data. To put one in a GitHub issue, upload the file with your environment's upload tool as an EXPIRING (presigned) link and pass it to `feedback to-issue --screenshot-url`.",examples:[["Save a screenshot","$0 --env prod feedback screenshot <feedbackId> --out ./feedback.webp"]]});feedbackId=f.String({required:!0,name:"feedbackId"});out=f.String("--out",{required:!0,description:"File to write (refused if it exists, unless --force)."});force=kn();async execute(){let n=_n(this.out,this.force),r=await(await this.caller()).query(x.platformFeedback.getById,{feedbackItemId:this.feedbackId});if(!r.screenshotUrl)throw new Error(`Feedback ${this.feedbackId} has no screenshot.`);let{bytes:i,contentType:o}=await sF(r.screenshotUrl);return await lu(n,i),this.print({feedbackId:this.feedbackId,file:n,bytes:i.byteLength,contentType:o},a=>[{field:"feedbackId",value:a.feedbackId},{field:"file",value:a.file},{field:"bytes",value:String(a.bytes)},{field:"contentType",value:a.contentType??"(none)"}]),0}};var pF=[Xl,xd,Sd,ed,nd,td,rd,id,od,dd,cd,ud,pd,md,fd,hd,gd,yd,sd,ad,ld,kd,bd,vd];function ln(e,n,t,r="--label"){if(e===void 0||e.trim()==="")throw new Error(`${t}: ${r} cannot be empty \u2014 the German text is required`);if(n===void 0||n.trim()==="")throw new Error(`${t}: ${r} needs ${r}-en too \u2014 the English text is required; every config text carries German AND English ([i18n/missingTranslation])`);return{de:e,en:n}}s(ln,"newLocalizedText");function h4(e){return e===void 0||e.en===void 0||e.en.trim()===""||e.en===e.de}s(h4,"isUntranslated");var g4={de:"the German text",en:"the English text"};function sb(e,n,t,r=g4){let{en:i}=n;if(n.de==="")throw new Error(`${t}: ${r.de} cannot be empty`);if(i==="")throw new Error(`${t}: ${r.en} cannot be empty \u2014 every config text needs both languages`);let o=n.de===e?.de?void 0:n.de;if(i===void 0){if(o===void 0)return;if(!h4(e))throw new Error(`${t}: carries an English text ("${e.en}") for the old German ("${e.de}") \u2014 pass ${r.en} for the new German too`);return{de:o,en:""}}let a=o??e?.de;if(a===void 0||a==="")throw new Error(`${t}: an English text needs the German one first \u2014 pass ${r.de}`);if(!(a===e?.de&&i===e?.en))return{de:a,en:i}}s(sb,"editedLocalizedText");function bn(e,n,t,r){let{de:i,en:o}=t;if(i===""&&t.clearable){if(o!==void 0&&o!=="")throw new Error(`${r}: an English text needs the German one`);delete e[n];return}let a=sb(e[n],{de:i,en:o},r);a!==void 0&&(e[n]=a)}s(bn,"setLocalizedText");function mF(e){let n=e.indexOf(":");if(n<0)return{id:e.trim(),de:"",en:void 0};let t=e.slice(0,n).trim(),r=e.slice(n+1),i=r.indexOf(":");return i<0?{id:t,de:r.trim(),en:void 0}:{id:t,de:r.slice(0,i).trim(),en:r.slice(i+1).trim()}}s(mF,"splitIdDeEn");var ab=class extends D{static{s(this,"FilesListCommand")}static paths=[["files","list"]];static usage=$.Usage({category:"Files",description:"List a tenant's file library (Vorlagen) / Dateien auflisten"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.tenantFiles.platformList,{client:t});return this.print(r,i=>i.map(o=>({key:o.key,label:o.label.de,labelEn:o.label.en,file:o.filename,size:o.sizeBytes===void 0?"-":String(o.sizeBytes),sha256:o.sha256===void 0?"-":o.sha256.slice(0,12),usedBy:o.references.map(a=>`${a.offerKey} r${a.offerRevision}/${a.fieldKey}`).join(", ")||"-"})),["key","label","labelEn","file","size","sha256","usedBy"]),0}},lb=class extends D{static{s(this,"FilesPutCommand")}static paths=[["files","put"]];static usage=$.Usage({category:"Files",description:"Create or replace a library file by key / Datei anlegen oder ersetzen",details:"Replacing keeps the key, so every form that attaches it offers the new file at once. Identical bytes are not stored twice; a changed label alone is still written. A new key needs --label AND --label-en. On an existing key, --label-en alone translates the stored German; a German change over a real English is refused without --label-en.",examples:[["Put a reference form","$0 --env staging --tenant test files put referenzformular ./Referenzformular.pdf --label 'Vorlage: Referenzformular' --label-en 'Template: reference form'"]]});key=f.String({name:"key"});file=f.String({name:"path"});label=f.String("--label",{description:"German label (required for a new key)"});labelEn=f.String("--label-en",{description:"English label (required for a new key)"});fileName=f.String("--file-name",{description:"Download name (default: the local file name)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=zw(this.file),i=(await Gl(n,t)).find(u=>u.key===this.key),o=this.fileName??r.filename,a=`files put "${this.key}"`,l;if(i===void 0)l=ln(this.label,this.labelEn,a);else if(this.label!==void 0||this.labelEn!==void 0){let u={label:{...i.label}};bn(u,"label",{de:this.label,en:this.labelEn},a),l=u.label}if(i!==void 0&&i.sha256===r.sha256&&l===void 0&&i.filename===o)return this.print({key:this.key,outcome:"unchanged"},u=>[{key:"key",value:u.key},{key:"outcome",value:u.outcome}]),0;let d=await aC(n,t,r.bytes,r.mimeType),c=await n.mutation(x.tenantFiles.platformPutFile,{client:t,key:this.key,...l!==void 0?{label:l}:{},filename:o,storageId:d});return this.print({key:this.key,outcome:c,sha256:r.sha256,sizeBytes:r.sizeBytes},u=>[{key:"key",value:u.key},{key:"outcome",value:String(u.outcome)},{key:"sha256",value:u.sha256},{key:"size",value:String(u.sizeBytes)}]),0}},db=class extends D{static{s(this,"FilesDeleteCommand")}static paths=[["files","delete"],["files","remove"],["files","rm"]];static usage=$.Usage({category:"Files",description:"Delete a library file \u2014 plan unless --confirm; refused while a form uses it / Datei l\xF6schen"});key=f.String({name:"key"});confirm=f.Boolean("--confirm",!1,{description:"Delete (without it, only the plan is printed)."});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(!this.confirm){let r=(await n.query(x.tenantFiles.platformList,{client:t})).find(o=>o.key===this.key);if(r===void 0)throw new Error(`Tenant "${t}" has no library file "${this.key}". See \`files list\`.`);let i=r.references.map(o=>`${o.offerKey} r${o.offerRevision}/${o.fieldKey}`);return this.print({key:this.key,filename:r.filename,usedBy:i,deleted:!1},o=>[{key:"would delete",value:`${o.key} (${o.filename})`},{key:"used by",value:o.usedBy.join(", ")||"- (none: the delete would go through)"},{key:"next",value:"re-run with --confirm"}]),0}return await n.mutation(x.tenantFiles.platformRemoveFile,{client:t,key:this.key}),this.print({key:this.key,deleted:!0},r=>[{key:"deleted",value:r.key}]),0}},hF=[ab,lb,db];function ma(e){if(!Se(e))throw new Error(`function-spec snapshot not found at ${e}. Regenerate with the package's \`spec\` script.`);return JSON.parse(he(e,"utf8"))}s(ma,"loadSpec");function er(e){return e.replace(/\.(js|ts):/,":")}s(er,"normalize");function cb(e){return e.functionType.toLowerCase()}s(cb,"kindOf");function y4(e){let n=e.args;return n?.value?Object.keys(n.value):[]}s(y4,"argNames");function gF(e,n={}){return e.functions.map(t=>({function:er(t.identifier),kind:cb(t),args:y4(t)})).filter(t=>n.kind?t.kind===n.kind.toLowerCase():!0).filter(t=>n.grep?t.function.toLowerCase().includes(n.grep.toLowerCase()):!0).sort((t,r)=>t.function.localeCompare(r.function))}s(gF,"listFunctions");function yF(e,n){let t=er(n),r=e.functions.find(a=>er(a.identifier)===t);if(r)return r;let i=e.functions.map(a=>er(a.identifier)).filter(a=>a.includes(t.split(":")[0]??t)||a.includes(t.split(":")[1]??"")).slice(0,8),o=i.length?` Did you mean: ${i.join(", ")}?`:"";throw new Error(`Unknown function "${n}".${o}`)}s(yF,"describeFunction");function tm(e,n,t){if(t!==void 0){if(t!=="query"&&t!=="mutation"&&t!=="action")throw new Error(`Unknown --kind '${t}' (expected query|mutation|action).`);let a=e.functions.find(d=>er(d.identifier)===er(n)),l=a===void 0?void 0:cb(a);if(l!==void 0&&l!==t)throw new Error(`"${n}" is a ${l} in the offline spec \u2014 --kind ${t} contradicts it.`);return t}let r=er(n),i=e.functions.find(a=>er(a.identifier)===r),o=i===void 0?void 0:cb(i);if(o!=="query"&&o!=="mutation"&&o!=="action")throw new Error(`"${n}" is not in the offline spec (a newer function, or a typo \u2014 see \`plexus-cli functions --grep\`); pass --kind query|mutation|action.`);if(o!=="query")throw new Error(`"${n}" is a ${o} \u2014 it writes; pass --kind ${o} (and check --env).`);return o}s(tm,"callKindFor");function Ko(e){let n=e;if(!n||typeof n.type!="string")return"unknown";switch(n.type){case"array":return`${Ko(n.value)}[]`;case"union":return(Array.isArray(n.value)?n.value.map(Ko):[]).join(" | ")||"union";case"literal":return JSON.stringify(n.value);case"id":return`id<${n.tableName??"?"}>`;case"object":return"object";default:return n.type}}s(Ko,"typeStr");function nm(e,n){let t=n;switch(t?.type){case"string":case"id":return typeof e=="string";case"number":case"float64":return typeof e=="number";case"int64":case"bigint":return typeof e=="number"&&Number.isInteger(e);case"boolean":return typeof e=="boolean";case"null":return e===null;case"literal":return e===t.value;case"union":return Array.isArray(t.value)&&t.value.some(r=>nm(e,r));case"array":return Array.isArray(e)&&e.every(r=>nm(r,t.value));case"object":{if(typeof e!="object"||e===null||Array.isArray(e))return!1;let r=t.value??{},i=e;return Object.keys(i).every(o=>o in r)&&Object.entries(r).every(([o,a])=>i[o]===void 0?a.optional===!0:nm(i[o],a.fieldType))}case"record":return typeof e=="object"&&e!==null&&!Array.isArray(e);default:return!0}}s(nm,"fits");function wF(e,n,t={}){let r=e.args?.value??{},i={...n},o=[];for(let[a,l]of Object.entries(r)){if(i[a]===void 0){l.optional!==!0&&o.push(`missing ${a} (${Ko(l.fieldType)})`);continue}let d=l.fieldType?.type;(d==="string"||d==="id")&&typeof i[a]!="string"&&t[a]!==void 0&&(i[a]=t[a]),nm(i[a],l.fieldType)||o.push(`${a}: expected ${Ko(l.fieldType)}, got ${JSON.stringify(i[a])}`)}for(let a of Object.keys(i))a in r||o.push(`unknown ${a} (takes: ${Object.keys(r).join(", ")||"nothing"})`);return{args:i,problems:o}}s(wF,"checkCallArgs");var ha=[z.resolve(import.meta.dirname,"spec.snapshot.json"),z.resolve(import.meta.dirname,"..","..","spec.snapshot.json")].find(e=>Se(e))??z.resolve(import.meta.dirname,"..","..","spec.snapshot.json");function ub(e){let n=e;return!n||n.type!=="object"||!n.value?null:Object.entries(n.value).map(([t,r])=>{let i=r;return{name:t,type:Ko(i.fieldType),optional:!!i.optional}})}s(ub,"objectFields");function w4(e){let n=e.functionType.toLowerCase();return n==="query"||n==="mutation"||n==="action"?n:e.functionType}s(w4,"kindLabel");var fb=class extends xe{static{s(this,"FunctionsCommand")}static paths=[["functions"]];static usage=$.Usage({category:"Introspection",description:"List callable public functions (offline; for `call`)."});kind=f.String("--kind",{description:"Filter by RPC kind (query|mutation|action)."});grep=f.String("--grep",{description:"Case-insensitive substring filter on the path."});async execute(){let n=ma(ha),t=gF(n,{kind:this.kind,grep:this.grep});return this.print(t,r=>r.map(i=>({function:i.function,kind:i.kind,args:i.args.join(",")})),["function","kind","args"]),0}},pb=class extends xe{static{s(this,"DescribeCommand")}static paths=[["describe"]];static usage=$.Usage({category:"Introspection",description:"Show one public function's args + return type (offline)."});fn=f.String({required:!0});async execute(){let n=ma(ha),t=yF(n,this.fn);if(this.json)return this.print(t),0;let r=er(t.identifier??this.fn),i=this.context.stdout;i.write(`${r} [${w4(t)}]
|
|
11227
|
+
`)}s(tF,"blockquote");function cF(e,n){let t=`type:${n}`;return ib(["label","create",t,"--repo",e,"--force","--color",f6[n]]),t}s(cF,"ensureTypeLabel");function uF(e){return`[${e.tags?.[0]?.name||"feedback"}] ${(e.summary||"").slice(0,80)}`}s(uF,"issueTitle");function fF(e,n,t){let r=["## Feedback",t,"",`Mandant **${e.tenantSlug}**`,`Gemeldet von: ${p6(e.submittedBy??{})}`,"","## Beschreibung",tF(e.summary??"")],i=[["Situation","situation"],["Ziel","goal"],["Ben\xF6tigte Information","needToSee"],["Ben\xF6tigte Aktion","needToDo"],["Grund","reason"],["Aktueller Workaround","currentWorkaround"]];for(let[o,a]of i){let l=e[a];typeof l=="string"&&l.length>0&&r.push("",`## ${o}`,tF(l))}return n&&r.push("","## Screenshot",``),r.filter(o=>o!==null).join(`
|
|
11228
|
+
`)}s(fF,"issueBody");function Zl(e){if(/^\d+$/.test(e))return Number.parseInt(e,10);let n=Date.parse(e);if(Number.isNaN(n))throw new Error(`Invalid date ${JSON.stringify(e)} \u2014 use ISO (e.g. 2026-06-20) or epoch ms.`);return n}s(Zl,"parseDateMs");async function em(e,n){if(n==="@me"||n==="me")return(await e.query(x.platformFeedback.whoAmI,{})).userId;if(!n.includes("@"))return n;let r=(await e.query(x.platformFeedback.listPlatformAdmins,{})).find(i=>i.email.toLowerCase()===n.toLowerCase());if(r===void 0)throw new Error(`No platform admin with email ${JSON.stringify(n)}.`);return r.userId}s(em,"resolveAssigneeUserId");var Xl=class extends D{static{s(this,"FeedbackListCommand")}static paths=[["feedback","list"]];static usage=$.Usage({category:"Feedback",description:"List feedback (active tenant, or --all-tenants for a platform admin)."});limit=f.String("--limit",{description:"Max rows (default 50)."});fetchAll=f.Boolean("--all",!1,{description:"Fetch every page."});allTenants=f.Boolean("--all-tenants",!1,{description:"Cross-tenant platform view (requires _platform.feedback.read)."});status=f.String("--status",{description:`Filter by status (${qo.join("|")}).`});withIssues=f.Boolean("--with-issues",!1,{description:"Only items linked to a GitHub issue."});withoutIssues=f.Boolean("--without-issues",!1,{description:"Only items NOT yet linked to a GitHub issue."});text=f.String("--text",{description:"Filter: summary or submitter name/email contains this text."});tagIds=f.Array("--tag",{description:"Filter: item carries any of these tag ids (repeatable)."});assignee=f.String("--assignee",{description:"Filter: assignee @me, userId, or email (platform; needs --all-tenants)."});deadlineFrom=f.String("--deadline-from",{description:"Filter: deadline >= ISO/epoch (platform; needs --all-tenants)."});deadlineTo=f.String("--deadline-to",{description:"Filter: deadline <= ISO/epoch (platform; needs --all-tenants)."});async execute(){let n=await this.caller(),t=this.limit===void 0?50:Number.parseInt(this.limit,10);if(Number.isNaN(t))throw new Error(`feedback list: --limit must be an integer, got "${this.limit}".`);let r=this.fetchAll?void 0:t,i=this.assignee||this.deadlineFrom||this.deadlineTo;if(!this.allTenants){if(this.withIssues||this.withoutIssues||i)throw new Error("--with-issues/--without-issues/--assignee/--deadline-* require --all-tenants (the GitHub link, assignee and deadline are platform-admin-only).");let d=this.requireTenant(n),c=await this.paginate(n,x.feedback.listTenant,{client:d},{max:r});return c=this.applyTextTagFilter(c),this.print(c),0}let o=this.parseStatus(),a={};o!==void 0&&(a.status=o),this.text!==void 0&&(a.text=this.text),this.tagIds&&this.tagIds.length>0&&(a.tagIds=this.tagIds),this.assignee!==void 0&&(a.assigneeUserId=await em(n,this.assignee)),this.deadlineFrom!==void 0&&(a.deadlineFrom=Zl(this.deadlineFrom)),this.deadlineTo!==void 0&&(a.deadlineTo=Zl(this.deadlineTo));let l=await this.paginate(n,x.platformFeedback.listAllPlatform,a,{max:r});return this.withIssues&&(l=l.filter(d=>d.githubIssue)),this.withoutIssues&&(l=l.filter(d=>!d.githubIssue)),this.print(l,d=>d.map(m6),["id","tenant","status","tags","summary","issue","resolved"]),0}applyTextTagFilter(n){let t=this.text?.trim().toLowerCase(),r=this.tagIds&&this.tagIds.length>0?new Set(this.tagIds):null;return n.filter(i=>!(t&&!`${i.summary??""} ${i.submittedBy?.name??""} ${i.submittedBy?.email??""}`.toLowerCase().includes(t)||r&&!(i.tags??[]).some(o=>r.has(o.id))))}parseStatus(){if(this.status!==void 0){if(!qo.includes(this.status))throw new Error(`feedback list: --status must be one of ${qo.join("|")}.`);return this.status}}};function m6(e){let n=e.githubIssue;return{id:e.id,tenant:e.tenantSlug,status:e.status,tags:(e.tags??[]).map(t=>t.name).join(", "),summary:(e.summary??"").slice(0,50),issue:n?`#${Xp(n)} (${n.state})`:"",resolved:e.resolved?"\u2713":""}}s(m6,"platformRow");var ed=class extends D{static{s(this,"FeedbackToIssueCommand")}static paths=[["feedback","to-issue"]];static usage=$.Usage({category:"Feedback",description:"Create + link a GitHub issue for a feedback item (idempotent)."});feedbackId=f.String({required:!0,name:"feedbackId"});repo=f.String("--repo",rb,{description:`Default ${rb}.`});issueType=f.String("--type",{description:`Triage type (${Zp.join("|")}) \u2014 added as a 'type:<t>' label.`});dryRun=f.Boolean("--dry-run",!1,{description:"Render the issue without creating it."});screenshotUrl=f.String("--screenshot-url",{description:"Hosted (expiring) link to the item's screenshot \u2014 required when the item has one. Save it with `feedback screenshot <id> --out <file>` first."});noScreenshot=f.Boolean("--no-screenshot",!1,{description:"File an item that has a screenshot without it."});async execute(){let n=await this.caller(),t=this.feedbackId,r=await n.query(x.platformFeedback.getById,{feedbackItemId:t}),i=r.githubIssue;if(i&&!this.dryRun)return this.print({feedbackId:this.feedbackId,issue:i.url,alreadyLinked:!0},g=>[{field:"feedbackId",value:g.feedbackId},{field:"issue",value:g.issue},{field:"alreadyLinked",value:"\u2713"}]),0;if(this.issueType!==void 0&&!Zp.includes(this.issueType))throw new Error(`Invalid --type ${JSON.stringify(this.issueType)} \u2014 expected one of ${Zp.join("|")}.`);let o=this.issueType,a=uF(r),l=dF(lF(n.convexUrl),r.tenantSlug,this.feedbackId),d=[rF,...o?[`type:${o}`]:[]],c=aF(this.feedbackId,!!r.screenshotUrl,{screenshotUrl:this.screenshotUrl,noScreenshot:this.noScreenshot}),u=fF(r,c,l);if(this.dryRun)return this.print({repo:this.repo,title:a,labels:d,hasScreenshot:!!r.screenshotUrl,screenshotUrl:c,body:u}),0;o&&cF(this.repo,o);let p=d.flatMap(g=>["--label",g]),m=iF("issue","create","--repo",this.repo,"--title",a,...p,"--body",u);if(!m.startsWith("https://github.com/"))throw new Error(`Unexpected gh output (not an issue URL): ${JSON.stringify(m)}`);let y=Number.parseInt(m.replace(/\/+$/,"").split("/").pop()??"",10);if(Number.isNaN(y))throw new Error(`Could not parse issue number from gh output: ${JSON.stringify(m)}`);let k=await n.mutation(x.platformFeedback.attachGithubIssue,{feedbackItemId:t,repo:this.repo,number:y,url:m,state:"open"});return this.print({feedbackId:this.feedbackId,issue:m,link:k},g=>[{field:"feedbackId",value:g.feedbackId},{field:"issue",value:g.issue}]),0}},nd=class extends D{static{s(this,"FeedbackSyncCommand")}static paths=[["feedback","sync"]];static usage=$.Usage({category:"Feedback",description:"Fetch GitHub issue state onto linked feedback (issue closed \u21D2 resolved)."});allTenants=f.Boolean("--all-tenants",!1);async execute(){let n=await this.caller();if(!this.allTenants)throw new Error("feedback sync requires --all-tenants (the GitHub link is platform-admin-only).");let r=(await this.paginate(n,x.platformFeedback.listAllPlatform,{})).filter(o=>o.githubIssue),i=[];for(let o of r){let a=o.githubIssue;if(!a)continue;let l=Xp(a),d=`${a.repo}#${l}`,c=ib(["issue","view",String(l),"--repo",a.repo,"--json","state,stateReason"]);if(!c.ok){i.push({id:o.id,issue:d,state:"error",resolved:""});continue}let u;try{u=JSON.parse(c.stdout)}catch{i.push({id:o.id,issue:d,state:"error",resolved:""});continue}let{state:p,reason:m}=oF(u.state??"",u.stateReason??"");await n.mutation(x.platformFeedback.syncGithubIssueState,{feedbackItemId:o.id,state:p,...m!==void 0?{stateReason:m}:{}}),i.push({id:o.id,issue:d,state:p,resolved:p==="closed"?"\u2713":""})}return this.print(i,o=>o.map(a=>({...a})),["id","issue","state","resolved"]),0}};var td=class extends D{static{s(this,"FeedbackSetStatusCommand")}static paths=[["feedback","set-status"]];static usage=$.Usage({category:"Feedback",description:"Manually move a feedback item to a board status."});feedbackId=f.String({required:!0,name:"feedbackId"});status=f.String({required:!0,name:"status"});async execute(){let n=await this.caller();if(!qo.includes(this.status))throw new Error(`feedback set-status: status must be one of ${qo.join("|")}.`);return await n.mutation(x.platformFeedback.setFeedbackStatus,{feedbackItemId:this.feedbackId,status:this.status}),this.print({feedbackId:this.feedbackId,status:this.status},t=>[{field:"feedbackId",value:t.feedbackId},{field:"status",value:t.status}]),0}},rd=class extends D{static{s(this,"FeedbackReassignCommand")}static paths=[["feedback","reassign"]];static usage=$.Usage({category:"Feedback",description:"Move a feedback item to another tenant (by target tenant slug)."});feedbackId=f.String({required:!0,name:"feedbackId"});tenantSlug=f.String({required:!0,name:"tenantSlug"});async execute(){let n=await this.caller(),t=await n.query(x.platformFeedback.listAllTenantsForAssignment,{}),r=t.find(i=>i.slug===this.tenantSlug);if(r===void 0){let i=t.map(o=>o.slug).join(", ");throw new Error(`feedback reassign: no tenant "${this.tenantSlug}". Available: ${i||"(none)"}.`)}return await n.mutation(x.platformFeedback.reassignTenant,{feedbackItemId:this.feedbackId,newTenantId:r.id}),this.print({feedbackId:this.feedbackId,tenantSlug:this.tenantSlug},i=>[{field:"feedbackId",value:i.feedbackId},{field:"tenantSlug",value:i.tenantSlug}]),0}},id=class extends D{static{s(this,"FeedbackReplyCommand")}static paths=[["feedback","reply"]];static usage=$.Usage({category:"Feedback",description:"Post a platform reply on a feedback item (public by default; --internal for a platform-only note)."});feedbackId=f.String({required:!0,name:"feedbackId"});body=f.String({required:!0,name:"body"});internal=f.Boolean("--internal",!1,{description:"Post as an internal note (not visible to the tenant)."});async execute(){let t=await(await this.caller()).mutation(x.platformFeedback.addComment,{feedbackItemId:this.feedbackId,body:this.body,visibility:this.internal?"internal":"public"});return this.print(t,r=>[{field:"id",value:r.id},{field:"visibility",value:r.visibility},{field:"author",value:r.authorName}]),0}},od=class extends D{static{s(this,"FeedbackCommentsCommand")}static paths=[["feedback","comments"]];static usage=$.Usage({category:"Feedback",description:"List the conversation (public replies + internal notes) on a feedback item."});feedbackId=f.String({required:!0,name:"feedbackId"});async execute(){let t=await(await this.caller()).query(x.platformFeedback.listComments,{feedbackItemId:this.feedbackId});return this.print(t,r=>r.map(i=>({id:i.id,visibility:i.visibility,author:i.authorName,body:i.body})),["id","visibility","author","body"]),0}},sd=class extends D{static{s(this,"FeedbackDeadlineCommand")}static paths=[["feedback","set-deadline"],["feedback","deadline"]];static usage=$.Usage({category:"Feedback",description:"Set or clear a feedback item's deadline (platform admin)."});feedbackId=f.String({required:!0,name:"feedbackId"});date=f.String({required:!1,name:"date"});clear=f.Boolean("--clear",!1,{description:"Clear the deadline."});async execute(){let n=await this.caller();if(!this.clear&&this.date===void 0)throw new Error("feedback deadline: pass a date (ISO/epoch) or --clear.");let t=this.clear?null:Zl(this.date);return await n.mutation(x.platformFeedback.setDeadline,{feedbackItemId:this.feedbackId,deadline:t}),this.print({feedbackId:this.feedbackId,deadline:t===null?"(cleared)":new Date(t).toISOString()},r=>[{field:"feedbackId",value:r.feedbackId},{field:"deadline",value:r.deadline}]),0}},ad=class extends D{static{s(this,"FeedbackAdminsCommand")}static paths=[["feedback","admins"]];static usage=$.Usage({category:"Feedback",description:"List platform admins (valid feedback assignees)."});async execute(){let t=await(await this.caller()).query(x.platformFeedback.listPlatformAdmins,{});return this.print(t,r=>r.map(i=>({userId:i.userId,name:i.name,email:i.email})),["userId","name","email"]),0}},ld=class extends D{static{s(this,"FeedbackAssignCommand")}static paths=[["feedback","assign"]];static usage=$.Usage({category:"Feedback",description:"Assign a feedback item to a platform admin (userId or email), or --clear."});feedbackId=f.String({required:!0,name:"feedbackId"});assignee=f.String({required:!1,name:"assignee"});clear=f.Boolean("--clear",!1,{description:"Unassign."});async execute(){let n=await this.caller();if(!this.clear&&this.assignee===void 0)throw new Error("feedback assign: pass a userId/email or --clear.");let t=this.clear?null:await em(n,this.assignee);return await n.mutation(x.platformFeedback.assign,{feedbackItemId:this.feedbackId,assigneeUserId:t}),this.print({feedbackId:this.feedbackId,assignee:t??"(cleared)"},r=>[{field:"feedbackId",value:r.feedbackId},{field:"assignee",value:r.assignee}]),0}};function wd(e){return[{field:"id",value:e.id},{field:"name",value:e.name},{field:"color",value:e.color},{field:"scope",value:e.scope}]}s(wd,"tagRows");function ob(e){if(e==="public"||e==="platform")return e;throw new Error(`Invalid visibility "${e}" \u2014 expected "public" or "platform".`)}s(ob,"parseTagScope");var dd=class extends D{static{s(this,"FeedbackTagsListCommand")}static paths=[["feedback","tags","list"]];static usage=$.Usage({category:"Feedback",description:"List the global feedback tag catalog (incl. platform-only tags)."});async execute(){let t=await(await this.caller()).query(x.feedbackTags.listAllTags,{});return this.print(t,r=>r.map(i=>({id:i.id,name:i.name,color:i.color,scope:i.scope})),["id","name","color","scope"]),0}},cd=class extends D{static{s(this,"FeedbackTagsCreateCommand")}static paths=[["feedback","tags","create"]];static usage=$.Usage({category:"Feedback",description:"Create a tag (platform admin). --color is a 6-hex code, e.g. d73a4a; --visibility is public (default) or platform."});name=f.String({required:!0,name:"name"});color=f.String("--color",{required:!0,description:"6-hex colour (no '#')."});visibility=f.String("--visibility",{description:"public (default) or platform (platform-admins only)."});async execute(){let t=await(await this.caller()).mutation(x.feedbackTags.createTag,{name:this.name,color:this.color,scope:this.visibility?ob(this.visibility):"public"});return this.print(t,wd),0}},ud=class extends D{static{s(this,"FeedbackTagsSetCommand")}static paths=[["feedback","tags","set"]];static usage=$.Usage({category:"Feedback",description:"Change a tag's name, colour and/or visibility (platform admin).",examples:[["Rename and recolour","$0 --env staging feedback tags set <tagId> --name Bug --color d73a4a"]]});tagId=f.String({required:!0,name:"tagId"});name=f.String("--name",{description:"New name."});color=f.String("--color",{description:"New 6-hex colour (no '#')."});visibility=f.String("--visibility",{description:"public (everyone) or platform (platform-admins only)."});async execute(){if(this.name===void 0&&this.color===void 0&&this.visibility===void 0)throw new Error("feedback tags set: pass at least one of --name, --color, --visibility.");let n=this.visibility===void 0?void 0:ob(this.visibility),t=await this.caller(),r=this.tagId,i,o=[];try{this.name!==void 0&&(i=await t.mutation(x.feedbackTags.renameTag,{tagId:r,name:this.name}),o.push("--name")),this.color!==void 0&&(i=await t.mutation(x.feedbackTags.recolorTag,{tagId:r,color:this.color}),o.push("--color")),n!==void 0&&(i=await t.mutation(x.feedbackTags.setTagVisibility,{tagId:r,scope:n}),o.push("--visibility"))}catch(a){throw o.length>0&&this.context.stderr.write(`feedback tags set: ${o.join(", ")} already applied.
|
|
11229
|
+
`),a}if(i===void 0)throw new Error("feedback tags set: no change was sent.");return this.print(i,wd),0}},fd=class extends D{static{s(this,"FeedbackTagsVisibilityCommand")}static paths=[["feedback","tags","visibility"]];tagId=f.String({required:!0,name:"tagId"});scope=f.String({required:!0,name:"scope"});async execute(){an(this.context.stderr,"feedback tags visibility","feedback tags set <tagId> --visibility <scope>");let t=await(await this.caller()).mutation(x.feedbackTags.setTagVisibility,{tagId:this.tagId,scope:ob(this.scope)});return this.print(t,wd),0}},pd=class extends D{static{s(this,"FeedbackTagsRenameCommand")}static paths=[["feedback","tags","rename"]];tagId=f.String({required:!0,name:"tagId"});name=f.String({required:!0,name:"name"});async execute(){an(this.context.stderr,"feedback tags rename","feedback tags set <tagId> --name <name>");let t=await(await this.caller()).mutation(x.feedbackTags.renameTag,{tagId:this.tagId,name:this.name});return this.print(t,wd),0}},md=class extends D{static{s(this,"FeedbackTagsRecolorCommand")}static paths=[["feedback","tags","recolor"]];tagId=f.String({required:!0,name:"tagId"});color=f.String({required:!0,name:"color"});async execute(){an(this.context.stderr,"feedback tags recolor","feedback tags set <tagId> --color <hex>");let t=await(await this.caller()).mutation(x.feedbackTags.recolorTag,{tagId:this.tagId,color:this.color});return this.print(t,wd),0}},hd=class extends D{static{s(this,"FeedbackTagsDeleteCommand")}static paths=[["feedback","tags","delete"]];static usage=$.Usage({category:"Feedback",description:"Delete a tag and detach it from all items (platform admin) \u2014 plan unless --confirm."});tagId=f.String({required:!0,name:"tagId"});confirm=f.Boolean("--confirm",!1,{description:"Delete (without it, only the plan is printed)."});async execute(){let n=await this.caller();if(!this.confirm){let t=(await n.query(x.feedbackTags.listAllTags,{})).find(r=>r.id===this.tagId);if(t===void 0)throw new Error(`No feedback tag ${this.tagId} \u2014 see \`feedback tags list\`.`);return this.print({tagId:t.id,name:t.name,deleted:!1},r=>[{field:"would delete",value:`${r.name} (${r.tagId}) \u2014 detached from every item`},{field:"next",value:"re-run with --confirm"}]),0}return await n.mutation(x.feedbackTags.deleteTag,{tagId:this.tagId}),this.print({tagId:this.tagId,deleted:!0},t=>[{field:"tagId",value:t.tagId},{field:"deleted",value:"\u2713"}]),0}},gd=class extends D{static{s(this,"FeedbackTagAttachCommand")}static paths=[["feedback","tag"]];static usage=$.Usage({category:"Feedback",description:"Attach an existing tag to a feedback item (uses the active --tenant)."});feedbackId=f.String({required:!0,name:"feedbackId"});tagId=f.String({required:!0,name:"tagId"});async execute(){let n=await this.caller(),t=this.requireTenant(n);return await n.mutation(x.feedbackTags.attachTag,{client:t,feedbackItemId:this.feedbackId,tagId:this.tagId}),this.print({feedbackId:this.feedbackId,tagId:this.tagId,attached:!0},r=>[{field:"feedbackId",value:r.feedbackId},{field:"tagId",value:r.tagId},{field:"attached",value:"\u2713"}]),0}},yd=class extends D{static{s(this,"FeedbackUntagCommand")}static paths=[["feedback","untag"]];static usage=$.Usage({category:"Feedback",description:"Detach a tag from a feedback item (uses the active --tenant)."});feedbackId=f.String({required:!0,name:"feedbackId"});tagId=f.String({required:!0,name:"tagId"});async execute(){let n=await this.caller(),t=this.requireTenant(n);return await n.mutation(x.feedbackTags.detachTag,{client:t,feedbackItemId:this.feedbackId,tagId:this.tagId}),this.print({feedbackId:this.feedbackId,tagId:this.tagId,detached:!0},r=>[{field:"feedbackId",value:r.feedbackId},{field:"tagId",value:r.tagId},{field:"detached",value:"\u2713"}]),0}};var kd=class extends D{static{s(this,"FeedbackLinkCommand")}static paths=[["feedback","link"]];static usage=$.Usage({category:"Feedback",description:"Link two feedback items together (platform admin)."});feedbackId=f.String({required:!0,name:"feedbackId"});otherId=f.String({required:!0,name:"otherFeedbackId"});async execute(){return await(await this.caller()).mutation(x.platformFeedback.linkItems,{feedbackItemId:this.feedbackId,otherFeedbackItemId:this.otherId}),this.print({a:this.feedbackId,b:this.otherId,linked:!0},t=>[{field:"feedbackId",value:t.a},{field:"linkedTo",value:t.b},{field:"linked",value:"\u2713"}]),0}},bd=class extends D{static{s(this,"FeedbackUnlinkCommand")}static paths=[["feedback","unlink"]];static usage=$.Usage({category:"Feedback",description:"Remove a link between two feedback items (platform admin)."});feedbackId=f.String({required:!0,name:"feedbackId"});otherId=f.String({required:!0,name:"otherFeedbackId"});async execute(){return await(await this.caller()).mutation(x.platformFeedback.unlinkItems,{feedbackItemId:this.feedbackId,otherFeedbackItemId:this.otherId}),this.print({a:this.feedbackId,b:this.otherId,unlinked:!0},t=>[{field:"feedbackId",value:t.a},{field:"unlinkedFrom",value:t.b},{field:"unlinked",value:"\u2713"}]),0}},vd=class extends D{static{s(this,"FeedbackLinksCommand")}static paths=[["feedback","links"]];static usage=$.Usage({category:"Feedback",description:"List the feedback items linked to a given item (platform admin)."});feedbackId=f.String({required:!0,name:"feedbackId"});async execute(){let t=await(await this.caller()).query(x.platformFeedback.listLinks,{feedbackItemId:this.feedbackId});return this.print(t,r=>r.map(i=>({id:i.id,status:i.status,tenant:i.tenantSlug,summary:i.summary})),["id","status","tenant","summary"]),0}};var xd=class extends D{static{s(this,"FeedbackCreateCommand")}static paths=[["feedback","create"]];static usage=$.Usage({category:"Feedback",description:"File platform-level feedback (tenant-less, no screenshot). Needs _platform.feedback.read."});summary=f.String("--summary",{required:!0,description:"Short one-line summary (required)."});tag=f.Array("--tag",{description:"Catalog tag id to attach (repeatable). Platform admins may attach internal tags."});situation=f.String("--situation",{description:"What happened."});goal=f.String("--goal",{description:"What you were trying to do."});needToSee=f.String("--need-to-see",{description:"What you expected to see."});needToDo=f.String("--need-to-do",{description:"What you needed to do."});reason=f.String("--reason",{description:"Why it matters."});workaround=f.String("--workaround",{description:"Current workaround, if any."});async execute(){if(this.summary.trim().length===0)throw new Error("feedback create: --summary must not be empty.");let n=this.tag??[],r=await(await this.caller()).mutation(x.platformFeedback.createPlatformFeedback,{summary:this.summary,...n.length>0?{tagIds:n}:{},...this.situation!==void 0?{situation:this.situation}:{},...this.goal!==void 0?{goal:this.goal}:{},...this.needToSee!==void 0?{needToSee:this.needToSee}:{},...this.needToDo!==void 0?{needToDo:this.needToDo}:{},...this.reason!==void 0?{reason:this.reason}:{},...this.workaround!==void 0?{currentWorkaround:this.workaround}:{},context:{pathname:"/cli",search:"",hash:"",pageTitle:"plexus-cli feedback create",viewport:{width:0,height:0,devicePixelRatio:1},locale:"de",timezone:"UTC"}});return this.print({feedbackId:r.feedbackId,tags:n.join(", "),summary:this.summary},i=>[{field:"feedbackId",value:i.feedbackId},{field:"tags",value:i.tags},{field:"summary",value:i.summary}]),0}};var Sd=class extends D{static{s(this,"FeedbackScreenshotCommand")}static paths=[["feedback","screenshot"]];static usage=$.Usage({category:"Feedback",description:"Save a feedback item's screenshot to a local file.",details:"Feedback screenshots can show customer data. To put one in a GitHub issue, upload the file with your environment's upload tool as an EXPIRING (presigned) link and pass it to `feedback to-issue --screenshot-url`.",examples:[["Save a screenshot","$0 --env prod feedback screenshot <feedbackId> --out ./feedback.webp"]]});feedbackId=f.String({required:!0,name:"feedbackId"});out=f.String("--out",{required:!0,description:"File to write (refused if it exists, unless --force)."});force=kn();async execute(){let n=_n(this.out,this.force),r=await(await this.caller()).query(x.platformFeedback.getById,{feedbackItemId:this.feedbackId});if(!r.screenshotUrl)throw new Error(`Feedback ${this.feedbackId} has no screenshot.`);let{bytes:i,contentType:o}=await sF(r.screenshotUrl);return await lu(n,i),this.print({feedbackId:this.feedbackId,file:n,bytes:i.byteLength,contentType:o},a=>[{field:"feedbackId",value:a.feedbackId},{field:"file",value:a.file},{field:"bytes",value:String(a.bytes)},{field:"contentType",value:a.contentType??"(none)"}]),0}};var pF=[Xl,xd,Sd,ed,nd,td,rd,id,od,dd,cd,ud,pd,md,fd,hd,gd,yd,sd,ad,ld,kd,bd,vd];function ln(e,n,t,r="--label"){if(e===void 0||e.trim()==="")throw new Error(`${t}: ${r} cannot be empty \u2014 the German text is required`);if(n===void 0||n.trim()==="")throw new Error(`${t}: ${r} needs ${r}-en too \u2014 the English text is required; every config text carries German AND English ([i18n/missingTranslation])`);return{de:e,en:n}}s(ln,"newLocalizedText");function h6(e){return e===void 0||e.en===void 0||e.en.trim()===""||e.en===e.de}s(h6,"isUntranslated");var g6={de:"the German text",en:"the English text"};function sb(e,n,t,r=g6){let{en:i}=n;if(n.de==="")throw new Error(`${t}: ${r.de} cannot be empty`);if(i==="")throw new Error(`${t}: ${r.en} cannot be empty \u2014 every config text needs both languages`);let o=n.de===e?.de?void 0:n.de;if(i===void 0){if(o===void 0)return;if(!h6(e))throw new Error(`${t}: carries an English text ("${e.en}") for the old German ("${e.de}") \u2014 pass ${r.en} for the new German too`);return{de:o,en:""}}let a=o??e?.de;if(a===void 0||a==="")throw new Error(`${t}: an English text needs the German one first \u2014 pass ${r.de}`);if(!(a===e?.de&&i===e?.en))return{de:a,en:i}}s(sb,"editedLocalizedText");function bn(e,n,t,r){let{de:i,en:o}=t;if(i===""&&t.clearable){if(o!==void 0&&o!=="")throw new Error(`${r}: an English text needs the German one`);delete e[n];return}let a=sb(e[n],{de:i,en:o},r);a!==void 0&&(e[n]=a)}s(bn,"setLocalizedText");function mF(e){let n=e.indexOf(":");if(n<0)return{id:e.trim(),de:"",en:void 0};let t=e.slice(0,n).trim(),r=e.slice(n+1),i=r.indexOf(":");return i<0?{id:t,de:r.trim(),en:void 0}:{id:t,de:r.slice(0,i).trim(),en:r.slice(i+1).trim()}}s(mF,"splitIdDeEn");var ab=class extends D{static{s(this,"FilesListCommand")}static paths=[["files","list"]];static usage=$.Usage({category:"Files",description:"List a tenant's file library (Vorlagen) / Dateien auflisten"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.tenantFiles.platformList,{client:t});return this.print(r,i=>i.map(o=>({key:o.key,label:o.label.de,labelEn:o.label.en,file:o.filename,size:o.sizeBytes===void 0?"-":String(o.sizeBytes),sha256:o.sha256===void 0?"-":o.sha256.slice(0,12),usedBy:o.references.map(a=>`${a.offerKey} r${a.offerRevision}/${a.fieldKey}`).join(", ")||"-"})),["key","label","labelEn","file","size","sha256","usedBy"]),0}},lb=class extends D{static{s(this,"FilesPutCommand")}static paths=[["files","put"]];static usage=$.Usage({category:"Files",description:"Create or replace a library file by key / Datei anlegen oder ersetzen",details:"Replacing keeps the key, so every form that attaches it offers the new file at once. Identical bytes are not stored twice; a changed label alone is still written. A new key needs --label AND --label-en. On an existing key, --label-en alone translates the stored German; a German change over a real English is refused without --label-en.",examples:[["Put a reference form","$0 --env staging --tenant test files put referenzformular ./Referenzformular.pdf --label 'Vorlage: Referenzformular' --label-en 'Template: reference form'"]]});key=f.String({name:"key"});file=f.String({name:"path"});label=f.String("--label",{description:"German label (required for a new key)"});labelEn=f.String("--label-en",{description:"English label (required for a new key)"});fileName=f.String("--file-name",{description:"Download name (default: the local file name)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=zw(this.file),i=(await Gl(n,t)).find(u=>u.key===this.key),o=this.fileName??r.filename,a=`files put "${this.key}"`,l;if(i===void 0)l=ln(this.label,this.labelEn,a);else if(this.label!==void 0||this.labelEn!==void 0){let u={label:{...i.label}};bn(u,"label",{de:this.label,en:this.labelEn},a),l=u.label}if(i!==void 0&&i.sha256===r.sha256&&l===void 0&&i.filename===o)return this.print({key:this.key,outcome:"unchanged"},u=>[{key:"key",value:u.key},{key:"outcome",value:u.outcome}]),0;let d=await aC(n,t,r.bytes,r.mimeType),c=await n.mutation(x.tenantFiles.platformPutFile,{client:t,key:this.key,...l!==void 0?{label:l}:{},filename:o,storageId:d});return this.print({key:this.key,outcome:c,sha256:r.sha256,sizeBytes:r.sizeBytes},u=>[{key:"key",value:u.key},{key:"outcome",value:String(u.outcome)},{key:"sha256",value:u.sha256},{key:"size",value:String(u.sizeBytes)}]),0}},db=class extends D{static{s(this,"FilesDeleteCommand")}static paths=[["files","delete"],["files","remove"],["files","rm"]];static usage=$.Usage({category:"Files",description:"Delete a library file \u2014 plan unless --confirm; refused while a form uses it / Datei l\xF6schen"});key=f.String({name:"key"});confirm=f.Boolean("--confirm",!1,{description:"Delete (without it, only the plan is printed)."});async execute(){let n=await this.caller(),t=this.requireTenant(n);if(!this.confirm){let r=(await n.query(x.tenantFiles.platformList,{client:t})).find(o=>o.key===this.key);if(r===void 0)throw new Error(`Tenant "${t}" has no library file "${this.key}". See \`files list\`.`);let i=r.references.map(o=>`${o.offerKey} r${o.offerRevision}/${o.fieldKey}`);return this.print({key:this.key,filename:r.filename,usedBy:i,deleted:!1},o=>[{key:"would delete",value:`${o.key} (${o.filename})`},{key:"used by",value:o.usedBy.join(", ")||"- (none: the delete would go through)"},{key:"next",value:"re-run with --confirm"}]),0}return await n.mutation(x.tenantFiles.platformRemoveFile,{client:t,key:this.key}),this.print({key:this.key,deleted:!0},r=>[{key:"deleted",value:r.key}]),0}},hF=[ab,lb,db];function ma(e){if(!Se(e))throw new Error(`function-spec snapshot not found at ${e}. Regenerate with the package's \`spec\` script.`);return JSON.parse(he(e,"utf8"))}s(ma,"loadSpec");function er(e){return e.replace(/\.(js|ts):/,":")}s(er,"normalize");function cb(e){return e.functionType.toLowerCase()}s(cb,"kindOf");function y6(e){let n=e.args;return n?.value?Object.keys(n.value):[]}s(y6,"argNames");function gF(e,n={}){return e.functions.map(t=>({function:er(t.identifier),kind:cb(t),args:y6(t)})).filter(t=>n.kind?t.kind===n.kind.toLowerCase():!0).filter(t=>n.grep?t.function.toLowerCase().includes(n.grep.toLowerCase()):!0).sort((t,r)=>t.function.localeCompare(r.function))}s(gF,"listFunctions");function yF(e,n){let t=er(n),r=e.functions.find(a=>er(a.identifier)===t);if(r)return r;let i=e.functions.map(a=>er(a.identifier)).filter(a=>a.includes(t.split(":")[0]??t)||a.includes(t.split(":")[1]??"")).slice(0,8),o=i.length?` Did you mean: ${i.join(", ")}?`:"";throw new Error(`Unknown function "${n}".${o}`)}s(yF,"describeFunction");function tm(e,n,t){if(t!==void 0){if(t!=="query"&&t!=="mutation"&&t!=="action")throw new Error(`Unknown --kind '${t}' (expected query|mutation|action).`);let a=e.functions.find(d=>er(d.identifier)===er(n)),l=a===void 0?void 0:cb(a);if(l!==void 0&&l!==t)throw new Error(`"${n}" is a ${l} in the offline spec \u2014 --kind ${t} contradicts it.`);return t}let r=er(n),i=e.functions.find(a=>er(a.identifier)===r),o=i===void 0?void 0:cb(i);if(o!=="query"&&o!=="mutation"&&o!=="action")throw new Error(`"${n}" is not in the offline spec (a newer function, or a typo \u2014 see \`plexus-cli functions --grep\`); pass --kind query|mutation|action.`);if(o!=="query")throw new Error(`"${n}" is a ${o} \u2014 it writes; pass --kind ${o} (and check --env).`);return o}s(tm,"callKindFor");function Ko(e){let n=e;if(!n||typeof n.type!="string")return"unknown";switch(n.type){case"array":return`${Ko(n.value)}[]`;case"union":return(Array.isArray(n.value)?n.value.map(Ko):[]).join(" | ")||"union";case"literal":return JSON.stringify(n.value);case"id":return`id<${n.tableName??"?"}>`;case"object":return"object";default:return n.type}}s(Ko,"typeStr");function nm(e,n){let t=n;switch(t?.type){case"string":case"id":return typeof e=="string";case"number":case"float64":return typeof e=="number";case"int64":case"bigint":return typeof e=="number"&&Number.isInteger(e);case"boolean":return typeof e=="boolean";case"null":return e===null;case"literal":return e===t.value;case"union":return Array.isArray(t.value)&&t.value.some(r=>nm(e,r));case"array":return Array.isArray(e)&&e.every(r=>nm(r,t.value));case"object":{if(typeof e!="object"||e===null||Array.isArray(e))return!1;let r=t.value??{},i=e;return Object.keys(i).every(o=>o in r)&&Object.entries(r).every(([o,a])=>i[o]===void 0?a.optional===!0:nm(i[o],a.fieldType))}case"record":return typeof e=="object"&&e!==null&&!Array.isArray(e);default:return!0}}s(nm,"fits");function wF(e,n,t={}){let r=e.args?.value??{},i={...n},o=[];for(let[a,l]of Object.entries(r)){if(i[a]===void 0){l.optional!==!0&&o.push(`missing ${a} (${Ko(l.fieldType)})`);continue}let d=l.fieldType?.type;(d==="string"||d==="id")&&typeof i[a]!="string"&&t[a]!==void 0&&(i[a]=t[a]),nm(i[a],l.fieldType)||o.push(`${a}: expected ${Ko(l.fieldType)}, got ${JSON.stringify(i[a])}`)}for(let a of Object.keys(i))a in r||o.push(`unknown ${a} (takes: ${Object.keys(r).join(", ")||"nothing"})`);return{args:i,problems:o}}s(wF,"checkCallArgs");var ha=[z.resolve(import.meta.dirname,"spec.snapshot.json"),z.resolve(import.meta.dirname,"..","..","spec.snapshot.json")].find(e=>Se(e))??z.resolve(import.meta.dirname,"..","..","spec.snapshot.json");function ub(e){let n=e;return!n||n.type!=="object"||!n.value?null:Object.entries(n.value).map(([t,r])=>{let i=r;return{name:t,type:Ko(i.fieldType),optional:!!i.optional}})}s(ub,"objectFields");function w6(e){let n=e.functionType.toLowerCase();return n==="query"||n==="mutation"||n==="action"?n:e.functionType}s(w6,"kindLabel");var fb=class extends xe{static{s(this,"FunctionsCommand")}static paths=[["functions"]];static usage=$.Usage({category:"Introspection",description:"List callable public functions (offline; for `call`)."});kind=f.String("--kind",{description:"Filter by RPC kind (query|mutation|action)."});grep=f.String("--grep",{description:"Case-insensitive substring filter on the path."});async execute(){let n=ma(ha),t=gF(n,{kind:this.kind,grep:this.grep});return this.print(t,r=>r.map(i=>({function:i.function,kind:i.kind,args:i.args.join(",")})),["function","kind","args"]),0}},pb=class extends xe{static{s(this,"DescribeCommand")}static paths=[["describe"]];static usage=$.Usage({category:"Introspection",description:"Show one public function's args + return type (offline)."});fn=f.String({required:!0});async execute(){let n=ma(ha),t=yF(n,this.fn);if(this.json)return this.print(t),0;let r=er(t.identifier??this.fn),i=this.context.stdout;i.write(`${r} [${w6(t)}]
|
|
11227
11230
|
|
|
11228
11231
|
`);let o=ub(t.args)??[];i.write(`args:${o.length?"":" (none)"}
|
|
11229
11232
|
`);for(let l of o)i.write(` ${l.name}: ${l.type}${l.optional?" (optional)":""}
|
|
@@ -11232,9 +11235,9 @@ returns: object
|
|
|
11232
11235
|
`);for(let l of a)i.write(` ${l.name}: ${l.type}${l.optional?" (optional)":""}
|
|
11233
11236
|
`)}else i.write(`
|
|
11234
11237
|
returns: ${Ko(t.returns)}
|
|
11235
|
-
`);return 0}},mb=class extends D{static{s(this,"CallCommand")}static paths=[["call"]];static usage=$.Usage({category:"Introspection",description:"Call any public Convex function by name (escape hatch)."});fn=f.String({required:!0});kind=f.String("--kind",{description:"Function kind: query|mutation|action. Without it only a query runs (checked against the offline spec); a write needs --kind."});args=f.Rest();effectiveKind=void 0;async execute(){let n=this.kind===void 0||Se(ha)?ma(ha):{functions:[]},t=tm(n,this.fn,this.kind),r=Zu(this.args),i=n.functions.find(p=>er(p.identifier)===er(this.fn)),{values:o,raw:a}=
|
|
11238
|
+
`);return 0}},mb=class extends D{static{s(this,"CallCommand")}static paths=[["call"]];static usage=$.Usage({category:"Introspection",description:"Call any public Convex function by name (escape hatch)."});fn=f.String({required:!0});kind=f.String("--kind",{description:"Function kind: query|mutation|action. Without it only a query runs (checked against the offline spec); a write needs --kind."});args=f.Rest();effectiveKind=void 0;async execute(){let n=this.kind===void 0||Se(ha)?ma(ha):{functions:[]},t=tm(n,this.fn,this.kind),r=Zu(this.args),i=n.functions.find(p=>er(p.identifier)===er(this.fn)),{values:o,raw:a}=k6(this.fn,i,r,this.tenant),l=o;if(i===void 0)this.context.stderr.write(`note: "${this.fn}" is not in the offline spec \u2014 arguments are not checked before the call
|
|
11236
11239
|
`);else{let p=wF(i,o,a);if(p.problems.length>0)throw new Error(`call ${this.fn}: ${p.problems.join("; ")} \u2014 see \`plexus-cli describe ${this.fn}\``);l=p.args}this.effectiveKind=t;let d=await this.caller(),c=Ha(this.fn),u;if(t==="query"){let p=c;u=await d.query(p,l)}else if(t==="mutation"){let p=c;u=await d.mutation(p,l)}else{let p=c;u=await d.action(p,l)}return this.context.stdout.write(`${JSON.stringify(u,(p,m)=>typeof m=="bigint"?m.toString():m,2)}
|
|
11237
|
-
`),0}};function k4(e,n,t,r){if(r===void 0)return t;if(n===void 0)throw new Ie(`call ${e}: --tenant needs the function in the offline spec to know its tenant argument \u2014 pass client=<slug> instead.`);if(!(ub(n.args)?.some(o=>o.name==="client")??!1))throw new Ie(`call ${e}: takes no client argument, so --tenant does not apply \u2014 drop it (see \`plexus-cli describe ${e}\`).`);if(t.values.client!==void 0&&t.values.client!==r)throw new Ie(`call ${e}: client=${JSON.stringify(t.values.client)} contradicts --tenant ${r} \u2014 name the tenant once.`);return{values:{...t.values,client:r},raw:{...t.raw,client:r}}}s(k4,"withTenantClient");var kF=[fb,pb,mb];async function rm(e){let n;try{n=await e.query(x.platformAdmin.listAllTenants,{})}catch(t){if(vi(t)?.code!=="FORBIDDEN")throw t;n=(await e.query(x.permissions.currentUserAccess,{})).users.map(i=>i.tenant).filter(i=>i!==null)}return n.filter(t=>t.slug.length>0)}s(rm,"accessibleTenants");function Hn(e,n,t){let r=e.de?.trim()??"",i=e.en?.trim()??"";if(r==="")throw new Error(`${n}: ${t.de} is required`);if(i==="")throw new Error(`${n}: ${t.en} is required \u2014 every name a reader sees needs German and English`);return{de:r,en:i}}s(Hn,"newName");function nr(e,n,t,r){let i=sb(e,{de:n.de?.trim(),en:n.en?.trim()},t,r);if(i!==void 0&&i.en.trim()==="")throw new Error(`${t}: there is no English name for "${i.de}" \u2014 pass ${r.en}; every name a reader sees needs German and English`);return i}s(nr,"editedName");function _e(e){return e.en===""||e.en===e.de?e.de:`${e.de} / ${e.en}`}s(_e,"showName");var bF=s(e=>e.configKey??e.slug,"unitRef");function Mt(e,n,t){let r=[];if(t!=="unit")for(let o of e.legalEntities)(o.id===n||o.configKey===n)&&r.push({kind:"legalEntity",node:o});if(t!=="legalEntity")for(let o of e.units)(o.id===n||o.configKey===n||o.slug===n)&&r.push({kind:"unit",node:o});if(r.length===1)return r[0];let i=t==="unit"?"unit":t==="legalEntity"?"legal entity":"unit or legal entity";throw r.length>1?new Error(`"${n}" names ${r.length} nodes (${r.map(o=>o.node.id).join(", ")}) \u2014 pass the id.`):new Error(`No ${i} "${n}" in this tenant. See \`org tree\` for ids and keys.`)}s(Mt,"findOrgNode");var im=["id","key","name","kind","code","pedagogic"];function om(e){return e.units.map(n=>({id:n.id,key:bF(n),name:_e(n.name),kind:n.kind,code:n.code??"",pedagogic:n.isPedagogic?"\u2713":""}))}s(om,"flatUnitRows");function vF(e){let n=[],t=s((o,a)=>e.units.filter(l=>l.legalEntityId===o&&l.parentUnitId===a),"unitsOf"),r=s((o,a)=>{n.push({id:o.id,node:`${" ".repeat(a)}${_e(o.name)}`,kind:o.isPedagogic?`${o.kind} (pedagogic)`:o.kind,key:bF(o),programs:String(o.programCount)});for(let l of t(o.legalEntityId,o.id))r(l,a+1)},"walkUnit"),i=s((o,a)=>{n.push({id:o.id,node:`${" ".repeat(a)}${o.name}`,kind:o.type,key:o.configKey??"\u2014",programs:""});for(let l of t(o.id,null))r(l,a+1);for(let l of e.legalEntities.filter(d=>d.parentLegalEntityId===o.id))i(l,a+1)},"walkEntity");for(let o of e.legalEntities.filter(a=>a.parentLegalEntityId===null))i(o,0);return n}s(vF,"treeRows");function xF(e,n){let t=[],r=[],i=s(a=>{for(let l of e.units.filter(d=>d.parentUnitId===a.id))i(l);t.push({kind:"unit",node:a})},"walkUnit"),o=s(a=>{for(let l of e.legalEntities.filter(d=>d.parentLegalEntityId===a.id))o(l);for(let l of e.units.filter(d=>d.legalEntityId===a.id&&d.parentUnitId===null))i(l);r.push({kind:"legalEntity",node:a})},"walkEntity");return n.kind==="unit"?i(n.node):o(n.node),[...t,...r]}s(xF,"subtreeDeletionOrder");function Ad(e){return e.kind==="unit"?`unit ${_e(e.node.name)} (${e.node.id})`:`legal entity ${e.node.name} (${e.node.id})`}s(Ad,"describeNode");function jo(e,n,t){if(!n.includes(e))throw new Error(`offer manifest: ${t} must be one of ${n.join("|")} (got "${e}")`)}s(jo,"assertEnum");var SF={de:"--name",en:"--name-en"};async function $t(e,n){return await e.query(x.organization.getOrgTree,{client:n})}s($t,"loadOrgTree");async function AF(e,n,t){let r=await $t(e,n),i=[...r.legalEntities,...r.units].find(o=>o.id===t);if(i?.configKey==null)throw new Error(`org: the node ${t} just created carries no config key.`);return i.configKey}s(AF,"createdKey");async function b4(e,n,t){t.kind==="unit"?await e.mutation(x.masterData.deleteUnit,{client:n,unitId:t.node.id}):await e.mutation(x.organization.deleteLegalEntity,{client:n,legalEntityId:t.node.id})}s(b4,"deleteNode");var hb=class extends D{static{s(this,"OrgTreeCommand")}static paths=[["org","tree"]];static usage=$.Usage({category:"Organisation",description:"Show the organisation tree: legal entities with their units, nested \u2014 or every unit as one row (--flat)."});flat=f.Boolean("--flat",!1,{description:"One row per unit (id, key, name, kind, code, pedagogic) instead of the nested tree"});async execute(){let n=await this.caller(),t=await $t(n,this.requireTenant(n));return this.flat?this.print(t,r=>om(r).map(i=>({...i})),im):this.print(t,r=>vF(r).map(i=>({...i})),["node","kind","key","programs","id"]),0}},gb=class extends D{static{s(this,"OrgLegalEntityCreateCommand")}static paths=[["org","legal-entity","create"]];static usage=$.Usage({category:"Organisation",description:"Create a legal entity (Tr\xE4ger or school group), optionally under a parent legal entity."});name=f.String("--name",{required:!0,description:"Name"});type=f.String("--type",{required:!0,description:Br.join("|")});parent=f.String("--parent",{description:"Parent legal entity \u2014 id or config key"});key=f.String("--key",{description:"Config key (kebab-case, unique in the tenant); default: derived from the (German) name \u2014 what config, bundles and `offer create --unit` name it by"});async execute(){let n=await this.caller(),t=this.requireTenant(n);jo(this.type,Br,"--type");let r=this.parent===void 0?null:Mt(await $t(n,t),this.parent,"legalEntity").node.id,i=await n.mutation(x.organization.createNode,{client:t,node:{kind:"legalEntity",name:this.name,type:this.type,parentId:r,...this.key===void 0?{}:{key:this.key}}}),o=await AF(n,t,i);return this.print({id:i,configKey:o},a=>[{key:"legal entity created",value:a.id},{key:"config key",value:a.configKey}]),0}},yb=class extends D{static{s(this,"OrgLegalEntitySetCommand")}static paths=[["org","legal-entity","set"],["org","legal-entity","update"]];static usage=$.Usage({category:"Organisation",description:"Rename, retype or move a legal entity. Unnamed fields keep their value."});ref=f.String({required:!0,name:"legalEntity"});name=f.String("--name",{description:"New name"});type=f.String("--type",{description:Br.join("|")});parent=f.String("--parent",{description:"New parent legal entity \u2014 id or config key"});root=f.Boolean("--root",!1,{description:"Move to the top level (no parent)"});key=f.String("--key",{description:"New config key (kebab-case). Sets the key of a keyless node; a re-key is refused while a process version, contract template, Stripe account, import source or open generation run still names the old one"});async execute(){if(this.parent!==void 0&&this.root)throw new Error("org legal-entity set: --parent or --root, not both.");let n=await this.caller(),t=this.requireTenant(n),r=await $t(n,t),{node:i}=Mt(r,this.ref,"legalEntity");this.type!==void 0&&jo(this.type,Br,"--type");let o=this.root?null:this.parent===void 0?i.parentLegalEntityId:Mt(r,this.parent,"legalEntity").node.id;return await n.mutation(x.organization.updateNode,{client:t,node:{kind:"legalEntity",id:i.id,name:this.name??i.name,...this.type===void 0?{}:{entityType:this.type},parentId:o,...this.key===void 0?{}:{key:this.key}}}),this.print({id:i.id},a=>[{key:"legal entity updated",value:a.id}]),0}},wb=class extends D{static{s(this,"OrgLegalEntityDeleteCommand")}static paths=[["org","legal-entity","delete"]];static usage=$.Usage({category:"Organisation",description:"Delete one legal entity (a Tr\xE4ger with its contract party) \u2014 plan unless --confirm. Refused while units, child legal entities, contract templates or contracts still name it \u2014 `org delete-subtree` removes a whole branch."});ref=f.String({required:!0,name:"legalEntity"});confirm=f.Boolean("--confirm",!1,{description:"Delete (without it, only the plan is printed)."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await $t(n,t),{node:i}=Mt(r,this.ref,"legalEntity");if(!this.confirm){let a=r.units.filter(d=>d.legalEntityId===i.id).length,l=r.legalEntities.filter(d=>d.parentLegalEntityId===i.id).length;return this.print({id:i.id,name:i.name,units:a,childLegalEntities:l,deleted:!1},d=>[{key:"would delete legal entity",value:`${d.name} (${d.id})`},{key:"units / child legal entities",value:`${d.units} / ${d.childLegalEntities} (any left refuses the delete)`},{key:"next",value:"re-run with --confirm"}]),0}let o=await n.mutation(x.organization.deleteLegalEntity,{client:t,legalEntityId:i.id});return this.print(o,a=>[{key:"legal entity deleted",value:a.name},{key:"rows removed",value:String(a.rows)}]),0}},kb=class extends D{static{s(this,"OrgUnitCreateCommand")}static paths=[["org","unit","create"]];static usage=$.Usage({category:"Organisation",description:"Create a unit under a legal entity or a parent unit. Not applyable by itself \u2014 `offer unit create` makes a pedagogic unit families apply to."});name=f.String("--name",{required:!0,description:"Name in German"});nameEn=f.String("--name-en",{required:!0,description:"Name in English"});kind=f.String("--kind",{description:`Unit kind (default school): ${Ft.join("|")}`});parent=f.String("--parent",{required:!0,description:"Legal entity or parent unit \u2014 id, config key or unit slug"});key=f.String("--key",{description:"Config key (kebab-case, unique in the tenant); default: derived from the (German) name \u2014 what config, bundles and `offer create --unit` name it by"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=this.kind??"school";jo(r,Ft,"--kind");let i=Mt(await $t(n,t),this.parent),o=await n.mutation(x.organization.createNode,{client:t,node:{kind:"unit",name:Hn({de:this.name,en:this.nameEn},"org unit create",SF),type:r,parentId:i.node.id,...this.key===void 0?{}:{key:this.key}}}),a=await AF(n,t,o);return this.print({id:o,configKey:a},l=>[{key:"unit created",value:l.id},{key:"config key",value:l.configKey}]),0}},bb=class extends D{static{s(this,"OrgUnitSetCommand")}static paths=[["org","unit","set"],["org","unit","update"]];static usage=$.Usage({category:"Organisation",description:"Rename, retype or move a unit within its legal entity. Unnamed fields keep their value."});ref=f.String({required:!0,name:"unit"});name=f.String("--name",{description:"New German name"});nameEn=f.String("--name-en",{description:"New English name"});kind=f.String("--kind",{description:Ft.join("|")});parent=f.String("--parent",{description:"New parent unit (same legal entity) \u2014 id, config key or slug"});root=f.Boolean("--root",!1,{description:"Place directly under its legal entity"});key=f.String("--key",{description:"New config key (kebab-case). Sets the key of a keyless node; a re-key is refused while a process version, contract template, Stripe account, import source or open generation run still names the old one"});async execute(){if(this.parent!==void 0&&this.root)throw new Error("org unit set: --parent or --root, not both.");let n=await this.caller(),t=this.requireTenant(n),r=await $t(n,t),{node:i}=Mt(r,this.ref,"unit");this.kind!==void 0&&jo(this.kind,Ft,"--kind");let o=nr(i.name,{de:this.name,en:this.nameEn},"org unit update",SF)??i.name,a=this.root?null:this.parent===void 0?i.parentUnitId:Mt(r,this.parent,"unit").node.id;return await n.mutation(x.organization.updateNode,{client:t,node:{kind:"unit",id:i.id,name:o,...this.kind===void 0?{}:{unitKind:this.kind},parentId:a,...this.key===void 0?{}:{key:this.key}}}),this.print({id:i.id},l=>[{key:"unit updated",value:l.id}]),0}},Ed=class extends D{static{s(this,"UnitDeletingCommand")}confirm=f.Boolean("--confirm",!1,{description:"Delete (without it, only the plan is printed)."});async deleteUnit(n){let t=await this.caller(),r=this.requireTenant(t),i=await $t(t,r),{node:o}=Mt(i,n,"unit");if(!this.confirm){let l=i.units.filter(d=>d.parentUnitId===o.id).length;return this.print({id:o.id,name:o.name,subUnits:l,deleted:!1},d=>[{key:"would delete unit",value:`${_e(d.name)} (${d.id})`},{key:"sub-units",value:`${d.subUnits} (any left \u2014 or a program or member \u2014 refuses the delete)`},{key:"next",value:"re-run with --confirm"}]),0}let a=await t.mutation(x.masterData.deleteUnit,{client:r,unitId:o.id});return this.print(a,l=>[{key:"unit deleted",value:_e(l.name)},{key:"pedagogy bridges",value:String(l.pedagogy)},{key:"profiles",value:String(l.profiles)},{key:"locations",value:String(l.locations)}]),0}},vb=class extends Ed{static{s(this,"OrgUnitDeleteCommand")}static paths=[["org","unit","delete"]];static usage=$.Usage({category:"Organisation",description:"Delete one unit with its pedagogy, profile and location rows \u2014 plan unless --confirm. Refused while it has programs (offers), sub-units or members."});ref=f.String({required:!0,name:"unit"});async execute(){return await this.deleteUnit(this.ref)}},xb=class extends D{static{s(this,"OrgDeleteSubtreeCommand")}static paths=[["org","delete-subtree"]];static usage=$.Usage({category:"Organisation",description:"Delete a legal entity or unit with everything below it \u2014 children first. Dry run unless --confirm.",details:`
|
|
11240
|
+
`),0}};function k6(e,n,t,r){if(r===void 0)return t;if(n===void 0)throw new Ie(`call ${e}: --tenant needs the function in the offline spec to know its tenant argument \u2014 pass client=<slug> instead.`);if(!(ub(n.args)?.some(o=>o.name==="client")??!1))throw new Ie(`call ${e}: takes no client argument, so --tenant does not apply \u2014 drop it (see \`plexus-cli describe ${e}\`).`);if(t.values.client!==void 0&&t.values.client!==r)throw new Ie(`call ${e}: client=${JSON.stringify(t.values.client)} contradicts --tenant ${r} \u2014 name the tenant once.`);return{values:{...t.values,client:r},raw:{...t.raw,client:r}}}s(k6,"withTenantClient");var kF=[fb,pb,mb];async function rm(e){let n;try{n=await e.query(x.platformAdmin.listAllTenants,{})}catch(t){if(vi(t)?.code!=="FORBIDDEN")throw t;n=(await e.query(x.permissions.currentUserAccess,{})).users.map(i=>i.tenant).filter(i=>i!==null)}return n.filter(t=>t.slug.length>0)}s(rm,"accessibleTenants");function Hn(e,n,t){let r=e.de?.trim()??"",i=e.en?.trim()??"";if(r==="")throw new Error(`${n}: ${t.de} is required`);if(i==="")throw new Error(`${n}: ${t.en} is required \u2014 every name a reader sees needs German and English`);return{de:r,en:i}}s(Hn,"newName");function nr(e,n,t,r){let i=sb(e,{de:n.de?.trim(),en:n.en?.trim()},t,r);if(i!==void 0&&i.en.trim()==="")throw new Error(`${t}: there is no English name for "${i.de}" \u2014 pass ${r.en}; every name a reader sees needs German and English`);return i}s(nr,"editedName");function _e(e){return e.en===""||e.en===e.de?e.de:`${e.de} / ${e.en}`}s(_e,"showName");var bF=s(e=>e.configKey??e.slug,"unitRef");function Mt(e,n,t){let r=[];if(t!=="unit")for(let o of e.legalEntities)(o.id===n||o.configKey===n)&&r.push({kind:"legalEntity",node:o});if(t!=="legalEntity")for(let o of e.units)(o.id===n||o.configKey===n||o.slug===n)&&r.push({kind:"unit",node:o});if(r.length===1)return r[0];let i=t==="unit"?"unit":t==="legalEntity"?"legal entity":"unit or legal entity";throw r.length>1?new Error(`"${n}" names ${r.length} nodes (${r.map(o=>o.node.id).join(", ")}) \u2014 pass the id.`):new Error(`No ${i} "${n}" in this tenant. See \`org tree\` for ids and keys.`)}s(Mt,"findOrgNode");var im=["id","key","name","kind","code","pedagogic"];function om(e){return e.units.map(n=>({id:n.id,key:bF(n),name:_e(n.name),kind:n.kind,code:n.code??"",pedagogic:n.isPedagogic?"\u2713":""}))}s(om,"flatUnitRows");function vF(e){let n=[],t=s((o,a)=>e.units.filter(l=>l.legalEntityId===o&&l.parentUnitId===a),"unitsOf"),r=s((o,a)=>{n.push({id:o.id,node:`${" ".repeat(a)}${_e(o.name)}`,kind:o.isPedagogic?`${o.kind} (pedagogic)`:o.kind,key:bF(o),programs:String(o.programCount)});for(let l of t(o.legalEntityId,o.id))r(l,a+1)},"walkUnit"),i=s((o,a)=>{n.push({id:o.id,node:`${" ".repeat(a)}${o.name}`,kind:o.type,key:o.configKey??"\u2014",programs:""});for(let l of t(o.id,null))r(l,a+1);for(let l of e.legalEntities.filter(d=>d.parentLegalEntityId===o.id))i(l,a+1)},"walkEntity");for(let o of e.legalEntities.filter(a=>a.parentLegalEntityId===null))i(o,0);return n}s(vF,"treeRows");function xF(e,n){let t=[],r=[],i=s(a=>{for(let l of e.units.filter(d=>d.parentUnitId===a.id))i(l);t.push({kind:"unit",node:a})},"walkUnit"),o=s(a=>{for(let l of e.legalEntities.filter(d=>d.parentLegalEntityId===a.id))o(l);for(let l of e.units.filter(d=>d.legalEntityId===a.id&&d.parentUnitId===null))i(l);r.push({kind:"legalEntity",node:a})},"walkEntity");return n.kind==="unit"?i(n.node):o(n.node),[...t,...r]}s(xF,"subtreeDeletionOrder");function Ad(e){return e.kind==="unit"?`unit ${_e(e.node.name)} (${e.node.id})`:`legal entity ${e.node.name} (${e.node.id})`}s(Ad,"describeNode");function jo(e,n,t){if(!n.includes(e))throw new Error(`offer manifest: ${t} must be one of ${n.join("|")} (got "${e}")`)}s(jo,"assertEnum");var SF={de:"--name",en:"--name-en"};async function $t(e,n){return await e.query(x.organization.getOrgTree,{client:n})}s($t,"loadOrgTree");async function AF(e,n,t){let r=await $t(e,n),i=[...r.legalEntities,...r.units].find(o=>o.id===t);if(i?.configKey==null)throw new Error(`org: the node ${t} just created carries no config key.`);return i.configKey}s(AF,"createdKey");async function b6(e,n,t){t.kind==="unit"?await e.mutation(x.masterData.deleteUnit,{client:n,unitId:t.node.id}):await e.mutation(x.organization.deleteLegalEntity,{client:n,legalEntityId:t.node.id})}s(b6,"deleteNode");var hb=class extends D{static{s(this,"OrgTreeCommand")}static paths=[["org","tree"]];static usage=$.Usage({category:"Organisation",description:"Show the organisation tree: legal entities with their units, nested \u2014 or every unit as one row (--flat)."});flat=f.Boolean("--flat",!1,{description:"One row per unit (id, key, name, kind, code, pedagogic) instead of the nested tree"});async execute(){let n=await this.caller(),t=await $t(n,this.requireTenant(n));return this.flat?this.print(t,r=>om(r).map(i=>({...i})),im):this.print(t,r=>vF(r).map(i=>({...i})),["node","kind","key","programs","id"]),0}},gb=class extends D{static{s(this,"OrgLegalEntityCreateCommand")}static paths=[["org","legal-entity","create"]];static usage=$.Usage({category:"Organisation",description:"Create a legal entity (Tr\xE4ger or school group), optionally under a parent legal entity."});name=f.String("--name",{required:!0,description:"Name"});type=f.String("--type",{required:!0,description:Br.join("|")});parent=f.String("--parent",{description:"Parent legal entity \u2014 id or config key"});key=f.String("--key",{description:"Config key (kebab-case, unique in the tenant); default: derived from the (German) name \u2014 what config, bundles and `offer create --unit` name it by"});async execute(){let n=await this.caller(),t=this.requireTenant(n);jo(this.type,Br,"--type");let r=this.parent===void 0?null:Mt(await $t(n,t),this.parent,"legalEntity").node.id,i=await n.mutation(x.organization.createNode,{client:t,node:{kind:"legalEntity",name:this.name,type:this.type,parentId:r,...this.key===void 0?{}:{key:this.key}}}),o=await AF(n,t,i);return this.print({id:i,configKey:o},a=>[{key:"legal entity created",value:a.id},{key:"config key",value:a.configKey}]),0}},yb=class extends D{static{s(this,"OrgLegalEntitySetCommand")}static paths=[["org","legal-entity","set"],["org","legal-entity","update"]];static usage=$.Usage({category:"Organisation",description:"Rename, retype or move a legal entity. Unnamed fields keep their value."});ref=f.String({required:!0,name:"legalEntity"});name=f.String("--name",{description:"New name"});type=f.String("--type",{description:Br.join("|")});parent=f.String("--parent",{description:"New parent legal entity \u2014 id or config key"});root=f.Boolean("--root",!1,{description:"Move to the top level (no parent)"});key=f.String("--key",{description:"New config key (kebab-case). Sets the key of a keyless node; a re-key is refused while a process version, contract template, Stripe account, import source or open generation run still names the old one"});async execute(){if(this.parent!==void 0&&this.root)throw new Error("org legal-entity set: --parent or --root, not both.");let n=await this.caller(),t=this.requireTenant(n),r=await $t(n,t),{node:i}=Mt(r,this.ref,"legalEntity");this.type!==void 0&&jo(this.type,Br,"--type");let o=this.root?null:this.parent===void 0?i.parentLegalEntityId:Mt(r,this.parent,"legalEntity").node.id;return await n.mutation(x.organization.updateNode,{client:t,node:{kind:"legalEntity",id:i.id,name:this.name??i.name,...this.type===void 0?{}:{entityType:this.type},parentId:o,...this.key===void 0?{}:{key:this.key}}}),this.print({id:i.id},a=>[{key:"legal entity updated",value:a.id}]),0}},wb=class extends D{static{s(this,"OrgLegalEntityDeleteCommand")}static paths=[["org","legal-entity","delete"]];static usage=$.Usage({category:"Organisation",description:"Delete one legal entity (a Tr\xE4ger with its contract party) \u2014 plan unless --confirm. Refused while units, child legal entities, contract templates or contracts still name it \u2014 `org delete-subtree` removes a whole branch."});ref=f.String({required:!0,name:"legalEntity"});confirm=f.Boolean("--confirm",!1,{description:"Delete (without it, only the plan is printed)."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await $t(n,t),{node:i}=Mt(r,this.ref,"legalEntity");if(!this.confirm){let a=r.units.filter(d=>d.legalEntityId===i.id).length,l=r.legalEntities.filter(d=>d.parentLegalEntityId===i.id).length;return this.print({id:i.id,name:i.name,units:a,childLegalEntities:l,deleted:!1},d=>[{key:"would delete legal entity",value:`${d.name} (${d.id})`},{key:"units / child legal entities",value:`${d.units} / ${d.childLegalEntities} (any left refuses the delete)`},{key:"next",value:"re-run with --confirm"}]),0}let o=await n.mutation(x.organization.deleteLegalEntity,{client:t,legalEntityId:i.id});return this.print(o,a=>[{key:"legal entity deleted",value:a.name},{key:"rows removed",value:String(a.rows)}]),0}},kb=class extends D{static{s(this,"OrgUnitCreateCommand")}static paths=[["org","unit","create"]];static usage=$.Usage({category:"Organisation",description:"Create a unit under a legal entity or a parent unit. Not applyable by itself \u2014 `offer unit create` makes a pedagogic unit families apply to."});name=f.String("--name",{required:!0,description:"Name in German"});nameEn=f.String("--name-en",{required:!0,description:"Name in English"});kind=f.String("--kind",{description:`Unit kind (default school): ${Ft.join("|")}`});parent=f.String("--parent",{required:!0,description:"Legal entity or parent unit \u2014 id, config key or unit slug"});key=f.String("--key",{description:"Config key (kebab-case, unique in the tenant); default: derived from the (German) name \u2014 what config, bundles and `offer create --unit` name it by"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=this.kind??"school";jo(r,Ft,"--kind");let i=Mt(await $t(n,t),this.parent),o=await n.mutation(x.organization.createNode,{client:t,node:{kind:"unit",name:Hn({de:this.name,en:this.nameEn},"org unit create",SF),type:r,parentId:i.node.id,...this.key===void 0?{}:{key:this.key}}}),a=await AF(n,t,o);return this.print({id:o,configKey:a},l=>[{key:"unit created",value:l.id},{key:"config key",value:l.configKey}]),0}},bb=class extends D{static{s(this,"OrgUnitSetCommand")}static paths=[["org","unit","set"],["org","unit","update"]];static usage=$.Usage({category:"Organisation",description:"Rename, retype or move a unit within its legal entity. Unnamed fields keep their value."});ref=f.String({required:!0,name:"unit"});name=f.String("--name",{description:"New German name"});nameEn=f.String("--name-en",{description:"New English name"});kind=f.String("--kind",{description:Ft.join("|")});parent=f.String("--parent",{description:"New parent unit (same legal entity) \u2014 id, config key or slug"});root=f.Boolean("--root",!1,{description:"Place directly under its legal entity"});key=f.String("--key",{description:"New config key (kebab-case). Sets the key of a keyless node; a re-key is refused while a process version, contract template, Stripe account, import source or open generation run still names the old one"});async execute(){if(this.parent!==void 0&&this.root)throw new Error("org unit set: --parent or --root, not both.");let n=await this.caller(),t=this.requireTenant(n),r=await $t(n,t),{node:i}=Mt(r,this.ref,"unit");this.kind!==void 0&&jo(this.kind,Ft,"--kind");let o=nr(i.name,{de:this.name,en:this.nameEn},"org unit update",SF)??i.name,a=this.root?null:this.parent===void 0?i.parentUnitId:Mt(r,this.parent,"unit").node.id;return await n.mutation(x.organization.updateNode,{client:t,node:{kind:"unit",id:i.id,name:o,...this.kind===void 0?{}:{unitKind:this.kind},parentId:a,...this.key===void 0?{}:{key:this.key}}}),this.print({id:i.id},l=>[{key:"unit updated",value:l.id}]),0}},Ed=class extends D{static{s(this,"UnitDeletingCommand")}confirm=f.Boolean("--confirm",!1,{description:"Delete (without it, only the plan is printed)."});async deleteUnit(n){let t=await this.caller(),r=this.requireTenant(t),i=await $t(t,r),{node:o}=Mt(i,n,"unit");if(!this.confirm){let l=i.units.filter(d=>d.parentUnitId===o.id).length;return this.print({id:o.id,name:o.name,subUnits:l,deleted:!1},d=>[{key:"would delete unit",value:`${_e(d.name)} (${d.id})`},{key:"sub-units",value:`${d.subUnits} (any left \u2014 or a program or member \u2014 refuses the delete)`},{key:"next",value:"re-run with --confirm"}]),0}let a=await t.mutation(x.masterData.deleteUnit,{client:r,unitId:o.id});return this.print(a,l=>[{key:"unit deleted",value:_e(l.name)},{key:"pedagogy bridges",value:String(l.pedagogy)},{key:"profiles",value:String(l.profiles)},{key:"locations",value:String(l.locations)}]),0}},vb=class extends Ed{static{s(this,"OrgUnitDeleteCommand")}static paths=[["org","unit","delete"]];static usage=$.Usage({category:"Organisation",description:"Delete one unit with its pedagogy, profile and location rows \u2014 plan unless --confirm. Refused while it has programs (offers), sub-units or members."});ref=f.String({required:!0,name:"unit"});async execute(){return await this.deleteUnit(this.ref)}},xb=class extends D{static{s(this,"OrgDeleteSubtreeCommand")}static paths=[["org","delete-subtree"]];static usage=$.Usage({category:"Organisation",description:"Delete a legal entity or unit with everything below it \u2014 children first. Dry run unless --confirm.",details:`
|
|
11238
11241
|
Lists every unit and legal entity below (and including) the node, in the
|
|
11239
11242
|
order they will be deleted: units before the legal entities carrying them,
|
|
11240
11243
|
every node after its children. A unit with programs refuses the whole run
|
|
@@ -11246,15 +11249,15 @@ returns: ${Ko(t.returns)}
|
|
|
11246
11249
|
`});ref=f.String({required:!0,name:"node"});confirm=f.Boolean("--confirm",!1,{description:"Required: actually delete (else dry run)"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await $t(n,t),i=xF(r,Mt(r,this.ref)),o=i.filter(d=>d.kind==="unit"&&d.node.programCount>0);if(o.length>0)throw new Error(`org delete-subtree: these units still have programs (offers) \u2014 remove or re-home them first: ${o.map(Ad).join(", ")}`);let a=this.context.stdout;if(!this.confirm)return this.json?this.print({tenant:t,deleted:!1,plan:i.map(d=>({kind:d.kind,id:d.node.id}))}):a.write(`DRY RUN \u2014 would delete ${i.length} node(s) from "${t}":
|
|
11247
11250
|
${i.map(d=>` ${Ad(d)}
|
|
11248
11251
|
`).join("")}Re-run with --confirm.
|
|
11249
|
-
`),0;let l=[];for(let d of i){try{await
|
|
11252
|
+
`),0;let l=[];for(let d of i){try{await b6(n,t,d)}catch(c){throw this.context.stderr.write(`Stopped at ${Ad(d)} after ${l.length} of ${i.length} deletion(s).
|
|
11250
11253
|
`),c}l.push(d.node.id),this.json||a.write(`deleted ${Ad(d)}
|
|
11251
|
-
`)}return this.json&&this.print({tenant:t,deleted:!0,ids:l}),0}},EF=[hb,gb,yb,wb,kb,bb,vb,xb];var Sb=class extends D{static{s(this,"WhoamiCommand")}static paths=[["whoami"]];static usage=$.Usage({category:"Identity",description:"Show the authenticated identity + permissions."});async execute(){let n=await this.caller(),t=await n.query(x.permissions.currentUserAccess,n.tenant?{client:n.tenant}:{});return this.print(t),0}},Td=class extends D{static{s(this,"TenantListingCommand")}async execute(){let n=await rm(await this.caller());return this.print(n,t=>t.map(r=>({slug:r.slug,name:r.name,id:r.id})),["slug","name","id"]),0}},Ab=class extends Td{static{s(this,"TenantsCommand")}static paths=[["tenants"]];static usage=$.Usage({category:"Identity",description:"List tenants you can access \u2014 every tenant for a platform admin."})},Eb=class extends D{static{s(this,"UnitsCommand")}static paths=[["units"]];async execute(){an(this.context.stderr,"units","org tree --flat");let n=await this.caller(),t=await $t(n,this.requireTenant(n));return this.print(t,r=>om(r).map(i=>({...i})),im),0}},TF=[Sb,Ab,Eb];import{createHash as
|
|
11252
|
-
`),0}},RF=[Tb,$b,Rb];var Ib=class extends D{static{s(this,"LeadsListCommand")}static paths=[["leads","list"],["interessenten","list"]];static usage=$.Usage({category:"Admission",description:"List Interessenten (leads) for the active tenant",details:"Lists the tenant's OPEN Interessenten (program interests), newest first. Converted leads are Bewerbungen (listed under applications); withdrawn/declined leads are removed. Use --json for the rich shape.",examples:[["List open Interessenten","plexus-cli leads list"],["As JSON","plexus-cli leads list --json"]]});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.leads.listForManagement,{client:t});return this.print(r,i=>i.map(o=>({name:o.personDisplayName??"\u2014",angebot:o.programName===null?"\u2014":_e(o.programName),stufe:o.stageName===null?"\u2014":_e(o.stageName),lauf:o.runName===null?"\u2014":_e(o.runName)})),["name","angebot","stufe","lauf"]),0}},IF=[Ib];function Mb(e){return e==null?"":new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z")}s(Mb,"ts");function PF(e){return e==null?"":`${Math.round((Date.now()-e)/6e4)}m`}s(PF,"ago");var OF=["queued","running","succeeded","failed","canceled"];function T4(e){let n=OF.find(t=>t===e);if(n===void 0)throw new Error(`jobs list: --status must be one of ${OF.join(" | ")}, got "${e}".`);return n}s(T4,"jobStatus");var Ob=class extends D{static{s(this,"JobsListCommand")}static paths=[["jobs","list"]];static usage=$.Usage({category:"Jobs",description:"List jobs newest-first (platform-admin). --status / --kind filter."});status=f.String("--status",{description:"queued | running | succeeded | failed | canceled"});kind=f.String("--kind",{description:"import | dummy | document_template_export"});limit=f.String("--limit",{description:"Max rows (default 100)."});all=f.Boolean("--all",!1,{description:"Fetch every page (ignores --limit)."});async execute(){let n=await this.caller(),t=this.all?void 0:Gu(this.limit,100),r=await this.paginate(n,x.jobs.listPage,this.status?{status:T4(this.status)}:{},{max:t,pageSize:Math.min(t??100,100)}),i=this.kind?r.filter(o=>o.kind===this.kind):r;return this.print(i,o=>o.map(a=>({id:a.id,kind:a.kind,status:a.status,tenant:a.tenantSlug??"",phase:a.phase,progress:a.progress?`${a.progress.current}/${a.progress.total}`:"",tries:`${a.attempts}/${a.maxAttempts}`,worker:a.leasedBy??"",updated:PF(a.updatedAt)})),["id","kind","status","tenant","phase","progress","tries","worker","updated"]),0}},Pb=class extends D{static{s(this,"JobsShowCommand")}static paths=[["jobs","show"]];static usage=$.Usage({category:"Jobs",description:"Show one job's full detail + per-attempt run timeline."});jobId=f.String({required:!0});async execute(){let t=await(await this.caller()).query(x.jobs.getDetail,{jobId:this.jobId});if(t===null)throw new Error(`Job ${this.jobId} not found.`);return this.print(t),0}},Nb=class extends D{static{s(this,"JobsLogsCommand")}static paths=[["jobs","logs"]];static usage=$.Usage({category:"Jobs",description:"Tail a job's captured worker output (oldest-first)."});jobId=f.String({required:!0});limit=f.String("--limit",{description:"Max lines (default 500, max 2000)."});async execute(){let t=await(await this.caller()).query(x.jobs.tailLog,{jobId:this.jobId,...this.limit?{limit:Number(this.limit)}:{}});return this.print(t,r=>r.map(i=>({at:Mb(i.at),stream:i.stream,text:i.text})),["at","stream","text"]),0}},_b=class extends D{static{s(this,"JobsCancelCommand")}static paths=[["jobs","cancel"]];static usage=$.Usage({category:"Jobs",description:"Cancel a queued/running job (the worker aborts; the domain row is failed) \u2014 irreversible, plan unless --confirm."});jobId=f.String({required:!0});confirm=f.Boolean("--confirm",!1,{description:"Cancel (without it, only the plan is printed)."});async execute(){let n=await this.caller();if(!this.confirm){let t=await n.query(x.jobs.getDetail,{jobId:this.jobId});if(t===null)throw new Error(`Job ${this.jobId} not found.`);return this.print({jobId:this.jobId,kind:t.kind,status:t.status,canceled:!1},r=>[{key:"would cancel",value:`${r.jobId} (${r.kind}, ${r.status})`},{key:"next",value:"re-run with --confirm"}]),0}return await n.mutation(x.jobs.cancel,{jobId:this.jobId}),this.print({canceled:this.jobId}),0}},Cb=class extends D{static{s(this,"WorkersLogsCommand")}static paths=[["platform","workers","logs"],["workers","logs"]];static usage=$.Usage({category:"Platform",description:"Tail one worker's captured stdout/stderr."});workerId=f.String({required:!0});limit=f.String("--limit",{description:"Max lines (default 500, max 2000)."});async execute(){let t=await(await this.caller()).query(x.workers.tailLog,{workerId:this.workerId,...this.limit?{limit:Number(this.limit)}:{}});return this.print(t,r=>r.map(i=>({at:Mb(i.at),stream:i.stream,text:i.text})),["at","stream","text"]),0}},Db=class extends D{static{s(this,"WorkersReaperStatusCommand")}static paths=[["platform","workers","reaper-status"],["workers","reaper-status"]];static usage=$.Usage({category:"Platform",description:"Show the last worker-reaper tick (confirm the cron is firing)."});async execute(){let t=await(await this.caller()).query(x.workers.reaperStatus,{});return t===null?(this.print({reaper:"no tick recorded yet"}),0):(this.print({...t,ranAt:Mb(t.ranAt)}),0)}},Fb=class extends D{static{s(this,"WorkersReapCommand")}static paths=[["platform","workers","reap"],["workers","reap"]];static usage=$.Usage({category:"Platform",description:"Force a reaper pass NOW (free dead leases / fail stalled jobs)."});async execute(){let t=await(await this.caller()).mutation(x.workers.reap,{});return this.print(t),0}},Lb=class extends D{static{s(this,"ImportsCleanupOrphansCommand")}static paths=[["platform","imports","cleanup-orphaned"],["imports","cleanup-orphaned"]];static usage=$.Usage({category:"Imports",description:"Find/fail orphaned import runs (status 'running' with no active job). Dry-run unless --confirm."});allTenants=f.Boolean("--all-tenants",!1,{description:"Scan every tenant (default: the active --tenant only)."});confirm=f.Boolean("--confirm",!1,{description:"Actually mark orphans failed (default: dry-run preview)."});async execute(){let n=await this.caller(),t=this.allTenants?void 0:this.requireTenant(n),r=await n.mutation(x.imports.failOrphanedRuns,{...t?{tenantSlug:t}:{},confirm:this.confirm});return this.print(r,i=>i.orphans.map(o=>({id:o.id,tenant:o.tenantSlug,importRunId:o.importRunId,phase:o.phase??"",updated:PF(o.updatedAt),action:i.confirmed?"failed":"would-fail"})),["id","tenant","importRunId","phase","updated","action"]),0}},NF=[Ob,Pb,Nb,_b,Cb,Db,Fb,Lb];var $4=/^(\d+)([mhd])$/,R4={m:6e4,h:36e5,d:864e5};function sm(e,n=Date.now()){let t=e.trim(),r=$4.exec(t);if(r!==null)return n-Number(r[1])*R4[r[2]];let i=/^\d{4}-\d{2}-\d{2}/.test(t)?Date.parse(t):Number.NaN;if(Number.isNaN(i))throw new Error(`--since "${e}": expected 90m, 24h, 2d or an ISO date like 2026-10-13T11:40Z`);return i}s(sm,"parseSince");function am(e){return e==null?"":new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z")}s(am,"ts");function Jb(e,n){if(e===void 0)throw new Error(`notifications ${n}: --locale is required (${We.join("|")}) \u2014 every letter exists in each language, and each is worded on its own`);if(!Kp(e))throw new Error(`notifications: --locale "${e}" is not a supported locale (${We.join("|")})`);return e}s(Jb,"parseLocale");function I4(e,n){let t={},r=s((i,o,a)=>{let l=o.indexOf("=");if(l<=0)throw new Error(`notifications letters: malformed ${i} "${o}" (expected <blockKey>=<value>)`);let d=o.slice(0,l).trim();if(!d)throw new Error(`notifications letters: malformed ${i} "${o}" (empty block key)`);if(d in t)throw new Error(`notifications letters: block "${d}" given twice \u2014 one value per block.`);t[d]=a(o.slice(l+1))},"put");for(let i of e??[])r("--slot",i,o=>o);for(let i of n??[])r("--slot-file",i,o=>he(o.trim(),"utf8"));return t}s(I4,"parseSlots");var qb=class extends D{static{s(this,"NotificationsListCommand")}static paths=[["platform","notifications","list"],["notifications","list"]];static usage=$.Usage({category:"Notifications",description:"List mail deliveries newest-first (platform-admin). Filter by --status, --template, --to, --since; the smtp column is the relay's answer (`250 \u2026 queued as <id>` = accepted).",examples:[["Dead-letters only","$0 notifications list --status dead"],["Everything still in flight","$0 notifications list --status queued"],["Did the login-page link to this address go out today?","$0 notifications list --template account.loginLink --to steffi@schule.example --since 24h"]]});status=f.String("--status",{description:"queued | sending | sent | skipped | dead"});template=f.String("--template",{description:"Only this letter, e.g. account.loginLink."});to=f.String("--to",{description:"Only deliveries to this address."});since=f.String("--since",{description:"Created since: 90m, 24h, 2d or an ISO date/time."});limit=f.String("--limit",{description:"Max rows (default 100)."});all=f.Boolean("--all",!1,{description:"Fetch every page (ignores --limit)."});async execute(){let n=await this.caller(),t=this.all?void 0:Gu(this.limit,100),r=await this.paginate(n,x.notifications.listPage,{...this.status?{status:this.status}:{},...this.template?{templateId:this.template}:{},...this.to?{recipientEmail:this.to}:{},...this.since?{since:sm(this.since)}:{}},{max:t,pageSize:Math.min(t??100,100)});return this.print(r,i=>i.map(o=>({id:o.id,template:o.templateId,status:o.status,tenant:o.tenantSlug??"",to:o.recipientEmail,files:o.attachmentCount>0?String(o.attachmentCount):"",tries:`${o.attempts}/${o.maxAttempts}`,error:o.errorCode??"",mode:o.transportMode??"",dup:o.possibleDuplicate?"!":"",created:am(o.createdAt),settled:am(o.settledAt),smtp:o.lastSmtpResponse??""})),["id","template","status","tenant","to","files","tries","error","mode","dup","created","settled","smtp"]),0}};function O4(e){if(e.letter===null)return{...e,attachments:[]};let{attachments:n,...t}=e.letter;return{...e,attachments:n.map(({filename:r,contentType:i,size:o})=>({filename:r,contentType:i,size:o})),letter:t}}s(O4,"showView");var Kb=class extends D{static{s(this,"NotificationsShowCommand")}static paths=[["platform","notifications","show"],["notifications","show"]];static usage=$.Usage({category:"Notifications",description:"Show one delivery in full: SMTP evidence, lease, sweeper bookkeeping, template summary."});deliveryId=f.String({required:!0});async execute(){let t=await(await this.caller()).query(x.notifications.getDetail,{deliveryId:this.deliveryId});if(t===null)throw new Error(`Delivery ${this.deliveryId} not found.`);return this.print(O4(t)),0}},jb=class extends D{static{s(this,"NotificationsRetryCommand")}static paths=[["platform","notifications","retry"],["notifications","retry"]];static usage=$.Usage({category:"Notifications",description:"Retry a DEAD delivery: a fresh attempt through the normal claim path. Check `show` first \u2014 a `possibleDuplicate` row may already have reached the recipient."});deliveryId=f.String({required:!0});async execute(){return await(await this.caller()).mutation(x.notifications.retry,{deliveryId:this.deliveryId}),this.print({deliveryId:this.deliveryId,status:"queued"}),0}},Bb=class extends D{static{s(this,"NotificationsSweeperStatusCommand")}static paths=[["platform","notifications","sweeper-status"],["notifications","sweeper-status"]];static usage=$.Usage({category:"Notifications",description:"Last tick of the notification sweeper cron (deadLastHour is the number to watch)."});async execute(){let t=await(await this.caller()).query(x.notifications.sweeperStatus,{});return t===null?(this.print({ranAt:null,note:"sweeper has not run since deploy"}),0):(this.print({...t,ranAt:am(t.ranAt),lastDeadAt:am(t.lastDeadAt)}),0)}},Vb=class extends D{static{s(this,"NotificationsSelfTestCommand")}static paths=[["platform","notifications","self-test"],["notifications","self-test"]];static usage=$.Usage({category:"Notifications",description:"Resolve the deployment's mail config, verify the SMTP connection + credentials, and send ONE test mail to --to with the raw SMTP transcript. A redirect deployment redirects the test too; dry sends nothing.",examples:[["Probe staging","$0 --env staging notifications self-test --to you@example.com"]]});to=f.String("--to",{required:!0,description:"Explicit recipient (never defaulted)."});async execute(){let t=await(await this.caller()).action(x.notificationActions.selfTest,{recipient:this.to});return this.print(t),t.ok?0:1}},Ub=class extends D{static{s(this,"NotificationsLettersListCommand")}static paths=[["notifications","letters","list"]];static usage=$.Usage({category:"Notifications",description:"The letter catalog for one school: what it can reword, and what it already did.",details:"Only the letters a school may actually write are listed \u2014 addressed to families, and with blocks to rewrite. A staff-internal letter or a retired one is not offered at all. `reworded` names the languages in which this school has already deviated from a letter.",examples:[["The catalog","$0 --tenant test notifications letters list"],["Only the reworded ones","$0 --tenant test notifications letters list --json"]]});async execute(){let n=await this.caller(),t=await n.query(x.notifications.letterWorkspace,{tenantSlug:this.requireTenant(n),locale:"de"});return this.print(t.letters,r=>r.map(i=>({template:i.id,label:i.label,blocks:i.slots.map(o=>o.key).join(", "),reworded:i.rewordedIn.join(", ")})),["template","label","blocks","reworded"]),0}},Gb=class extends D{static{s(this,"NotificationsLettersShowCommand")}static paths=[["notifications","letters","show"]];static usage=$.Usage({category:"Notifications",description:"One letter block by block: the current text, whether it deviates, and the placeholders it may use.",examples:[["The welcome letter","$0 --tenant test notifications letters show applicant.welcome --locale de"],["Its English version","$0 --tenant test notifications letters show applicant.welcome --locale en"]]});templateId=f.String({required:!0});locale=f.String("--locale",{description:`Letter language (${We.join("|")}) \u2014 required; each language is worded on its own`});async execute(){let n=await this.caller(),t=await n.query(x.notifications.letterWorkspace,{tenantSlug:this.requireTenant(n),locale:Jb(this.locale,"letters show")}),r=t.letters.find(i=>i.id===this.templateId);if(r===void 0)throw new Error(`notifications letters show: "${this.templateId}" is not a letter this school may reword \u2014 known: ${t.letters.map(i=>i.id).join(", ")}`);if(!this.json){let i=r.placeholders.map(o=>`{{${o.key}}}${o.required?" (Pflicht)":""}`).join(", ");this.context.stdout.write(`${r.label} \u2014 ${r.occasion.de}
|
|
11254
|
+
`)}return this.json&&this.print({tenant:t,deleted:!0,ids:l}),0}},EF=[hb,gb,yb,wb,kb,bb,vb,xb];var Sb=class extends D{static{s(this,"WhoamiCommand")}static paths=[["whoami"]];static usage=$.Usage({category:"Identity",description:"Show the authenticated identity + permissions."});async execute(){let n=await this.caller(),t=await n.query(x.permissions.currentUserAccess,n.tenant?{client:n.tenant}:{});return this.print(t),0}},Td=class extends D{static{s(this,"TenantListingCommand")}async execute(){let n=await rm(await this.caller());return this.print(n,t=>t.map(r=>({slug:r.slug,name:r.name,id:r.id})),["slug","name","id"]),0}},Ab=class extends Td{static{s(this,"TenantsCommand")}static paths=[["tenants"]];static usage=$.Usage({category:"Identity",description:"List tenants you can access \u2014 every tenant for a platform admin."})},Eb=class extends D{static{s(this,"UnitsCommand")}static paths=[["units"]];async execute(){an(this.context.stderr,"units","org tree --flat");let n=await this.caller(),t=await $t(n,this.requireTenant(n));return this.print(t,r=>om(r).map(i=>({...i})),im),0}},TF=[Sb,Ab,Eb];import{createHash as v6}from"node:crypto";var x6={".csv":"text/csv",".mdb":"application/x-msaccess",".accdb":"application/x-msaccess",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".xls":"application/vnd.ms-excel",".json":"application/json",".xml":"application/xml",".zip":"application/zip"};function S6(e){return x6[z.extname(e).toLowerCase()]??"application/octet-stream"}s(S6,"guessContentType");async function A6(e,n,t,r){let i=z.resolve(r),o;try{o=he(i)}catch{throw new Error(`File not found: ${r}`)}let a=z.basename(i),l=S6(a),{uploadUrl:d,uploadTicket:c}=await e.mutation(x.imports.generateUploadUrl,{client:n,configKey:t}),u=await e.upload(d,new Uint8Array(o),l);return await e.mutation(x.uploads.registerUpload,{uploadTicket:c,storageId:u}),{storageId:u,fileName:a,fileSize:o.length,fileContentType:l,fileSha256:v6("sha256").update(o).digest("hex")}}s(A6,"uploadImportFile");var Tb=class extends D{static{s(this,"ImportsStatusCommand")}static paths=[["imports","status"]];static usage=$.Usage({category:"Imports",description:"Show the active tenant's import controls + recent runs."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.imports.model,{client:t});return this.print({canStartManualImports:r.canStartManualImports,manualControls:r.manualControls,runs:r.runs},i=>i.manualControls.map(o=>({config:o.configKey,kind:o.sourceKind,requiresFile:o.requiresFile?"\u2713":"",canStart:o.canStart?"\u2713":"",reason:o.disabledReason??""})),["config","kind","requiresFile","canStart","reason"]),0}};function $F(e,n){return e.query(x.imports.model,{client:n})}s($F,"loadModel");async function E6(e,n,t){let r=await $F(e,n),i=r.manualControls.find(o=>o.configKey===t);if(i===void 0){let o=r.manualControls.map(a=>a.configKey).join(", ")||"(none)";throw new Error(`imports trigger: tenant "${n}" has no manual import "${t}". Known: ${o}.`)}return i}s(E6,"findControl");var $b=class extends D{static{s(this,"ImportsTriggerCommand")}static paths=[["imports","trigger"]];static usage=$.Usage({category:"Imports",description:"Trigger a manual import for the active tenant \u2014 destructive, plan unless --confirm.",details:"Without --confirm nothing is sent but reads: the plan names the import, its source and whether it can start. --confirm starts the real run; --probe --confirm runs the importer without committing (a test job). On production --allow-prod is required as well. The Engage password comes from --engage-password-stdin, --engage-password-file or PLEXUS_ENGAGE_PASSWORD \u2014 never from an argument.",examples:[["Plan","$0 --env staging --tenant <slug> imports trigger --config <configKey> --file ./export.mdb"],["Run","$0 --env staging --tenant <slug> imports trigger --config <configKey> --file ./export.mdb --confirm"]]});configKey=f.String("--config",{required:!0,description:"configKey."});file=f.String("--file",{description:"Source file to upload (when required)."});limit=f.String("--limit",{description:"Cap primary rows (testing)."});probe=f.Boolean("--probe",!1,{description:"With --confirm: run the importer without committing (starts a test job)."});confirm=f.Boolean("--confirm",!1,{description:"Start the import (without it, only the plan is printed)."});engageUser=f.String("--engage-user",{description:"Engage username (or PLEXUS_ENGAGE_USER)."});engagePasswordStdin=f.Boolean("--engage-password-stdin",!1,{description:"Read the Engage password from stdin."});engagePasswordFile=f.String("--engage-password-file",{description:"Read the Engage password from this file."});retiredDryRun=f.Boolean("--dry-run",!1,{hidden:!0});retiredEngagePassword=f.String("--engage-password",{hidden:!0});async execute(){Ju(this.retiredEngagePassword,"--engage-password","Pipe it in with --engage-password-stdin, pass --engage-password-file <path>, or set PLEXUS_ENGAGE_PASSWORD."),this.retiredDryRun&&an(this.context.stderr,"--dry-run","the default plan (or --probe --confirm for a server test run)");let n=this.probe||this.retiredDryRun,t=this.limit===void 0?void 0:Number.parseInt(this.limit,10);if(t!==void 0&&Number.isNaN(t))throw new Error(`imports trigger: --limit must be an integer, got "${this.limit}".`);if(this.file!==void 0&&!Se(z.resolve(this.file)))throw new Error(`File not found: ${this.file}`);let r=await this.caller(),i=this.requireTenant(r),o=await E6(r,i,this.configKey);if(o.requiresFile&&this.file===void 0)throw new Error(`imports trigger: "${this.configKey}" needs a source file \u2014 pass --file <path>.`);if(!this.confirm){let u={tenant:i,config:o.configKey,kind:o.sourceKind,file:this.file??null,canStart:o.canStart,reason:o.disabledReason??null,run:n?"probe (test job, nothing committed)":"real import (destructive)",started:!1};return this.print(u,p=>[{field:"would start",value:`${p.run} \u2014 ${p.config} (${p.kind}) in "${p.tenant}"`},{field:"file",value:p.file??"\u2014"},{field:"can start",value:p.canStart?"yes":`no \u2014 ${p.reason??"refused"}`},{field:"next",value:"re-run with --confirm"}]),0}let a=this.engagePasswordStdin||this.engagePasswordFile!==void 0?await ms({stdin:this.engagePasswordStdin,file:this.engagePasswordFile},ps(this.context.stdin),{stdin:"--engage-password-stdin",file:"--engage-password-file"}):process.env.PLEXUS_ENGAGE_PASSWORD,l=this.engageUser??process.env.PLEXUS_ENGAGE_USER,d=this.file?await A6(r,i,this.configKey,this.file):{},c=await r.mutation(x.imports.enqueueManualImport,{client:i,configKey:this.configKey,dryRun:n,confirmation:n?"":i,...t!==void 0?{limit:t}:{},...l?{engageUsername:l}:{},...a?{engagePassword:a}:{},...d});return this.print(c,u=>[{field:"jobId",value:u.jobId},{field:"runId",value:u.runId},{field:"importRunId",value:u.importRunId}]),0}},Rb=class extends D{static{s(this,"ImportsTriggerAllCommand")}static paths=[["platform","imports","trigger-all"],["imports","trigger-all"]];static usage=$.Usage({category:"Imports",description:"Trigger every file-less import across all accessible tenants \u2014 bulk, plan unless --confirm (--probe --confirm: test jobs only)."});probe=f.Boolean("--probe",!1,{description:"With --confirm: run each importer without committing (test jobs)."});confirm=f.Boolean("--confirm",!1,{description:"Start the imports (without it, only the plan is printed)."});retiredExecute=f.Boolean("--execute",!1,{hidden:!0});async execute(){let n=await this.caller(),t=await rm(n),r=[];for(let o of t){let a=o.slug,l=await $F(n,a).catch(d=>d instanceof Error?d:new Error(String(d)));if(l instanceof Error){r.push({tenant:a,config:"",result:`model failed: ${l.message}`});continue}for(let d of l.manualControls){if(d.requiresFile){r.push({tenant:a,config:d.configKey,result:"skipped: requires a file"});continue}if(!this.confirm){r.push({tenant:a,config:d.configKey,result:d.canStart?"would start":`would refuse: ${d.disabledReason??"cannot start"}`});continue}try{let c=await n.mutation(x.imports.enqueueManualImport,{client:a,configKey:d.configKey,dryRun:this.probe,confirmation:this.probe?"":a});r.push({tenant:a,config:d.configKey,result:c.runId})}catch(c){r.push({tenant:a,config:d.configKey,result:`error: ${kt(c)}`})}}}let i=this.confirm?this.probe?"probe":"run":"plan";return this.print({mode:i,results:r},o=>o.results.map(a=>({...a})),["tenant","config","result"]),this.confirm||this.context.stderr.write(`Plan only \u2014 re-run with --confirm to start them.
|
|
11255
|
+
`),0}},RF=[Tb,$b,Rb];var Ib=class extends D{static{s(this,"LeadsListCommand")}static paths=[["leads","list"],["interessenten","list"]];static usage=$.Usage({category:"Admission",description:"List Interessenten (leads) for the active tenant",details:"Lists the tenant's OPEN Interessenten (program interests), newest first. Converted leads are Bewerbungen (listed under applications); withdrawn/declined leads are removed. Use --json for the rich shape.",examples:[["List open Interessenten","plexus-cli leads list"],["As JSON","plexus-cli leads list --json"]]});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.leads.listForManagement,{client:t});return this.print(r,i=>i.map(o=>({name:o.personDisplayName??"\u2014",angebot:o.programName===null?"\u2014":_e(o.programName),stufe:o.stageName===null?"\u2014":_e(o.stageName),lauf:o.runName===null?"\u2014":_e(o.runName)})),["name","angebot","stufe","lauf"]),0}},IF=[Ib];function Mb(e){return e==null?"":new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z")}s(Mb,"ts");function PF(e){return e==null?"":`${Math.round((Date.now()-e)/6e4)}m`}s(PF,"ago");var OF=["queued","running","succeeded","failed","canceled"];function T6(e){let n=OF.find(t=>t===e);if(n===void 0)throw new Error(`jobs list: --status must be one of ${OF.join(" | ")}, got "${e}".`);return n}s(T6,"jobStatus");var Ob=class extends D{static{s(this,"JobsListCommand")}static paths=[["jobs","list"]];static usage=$.Usage({category:"Jobs",description:"List jobs newest-first (platform-admin). --status / --kind filter."});status=f.String("--status",{description:"queued | running | succeeded | failed | canceled"});kind=f.String("--kind",{description:"import | dummy | document_template_export"});limit=f.String("--limit",{description:"Max rows (default 100)."});all=f.Boolean("--all",!1,{description:"Fetch every page (ignores --limit)."});async execute(){let n=await this.caller(),t=this.all?void 0:Gu(this.limit,100),r=await this.paginate(n,x.jobs.listPage,this.status?{status:T6(this.status)}:{},{max:t,pageSize:Math.min(t??100,100)}),i=this.kind?r.filter(o=>o.kind===this.kind):r;return this.print(i,o=>o.map(a=>({id:a.id,kind:a.kind,status:a.status,tenant:a.tenantSlug??"",phase:a.phase,progress:a.progress?`${a.progress.current}/${a.progress.total}`:"",tries:`${a.attempts}/${a.maxAttempts}`,worker:a.leasedBy??"",updated:PF(a.updatedAt)})),["id","kind","status","tenant","phase","progress","tries","worker","updated"]),0}},Pb=class extends D{static{s(this,"JobsShowCommand")}static paths=[["jobs","show"]];static usage=$.Usage({category:"Jobs",description:"Show one job's full detail + per-attempt run timeline."});jobId=f.String({required:!0});async execute(){let t=await(await this.caller()).query(x.jobs.getDetail,{jobId:this.jobId});if(t===null)throw new Error(`Job ${this.jobId} not found.`);return this.print(t),0}},Nb=class extends D{static{s(this,"JobsLogsCommand")}static paths=[["jobs","logs"]];static usage=$.Usage({category:"Jobs",description:"Tail a job's captured worker output (oldest-first)."});jobId=f.String({required:!0});limit=f.String("--limit",{description:"Max lines (default 500, max 2000)."});async execute(){let t=await(await this.caller()).query(x.jobs.tailLog,{jobId:this.jobId,...this.limit?{limit:Number(this.limit)}:{}});return this.print(t,r=>r.map(i=>({at:Mb(i.at),stream:i.stream,text:i.text})),["at","stream","text"]),0}},_b=class extends D{static{s(this,"JobsCancelCommand")}static paths=[["jobs","cancel"]];static usage=$.Usage({category:"Jobs",description:"Cancel a queued/running job (the worker aborts; the domain row is failed) \u2014 irreversible, plan unless --confirm."});jobId=f.String({required:!0});confirm=f.Boolean("--confirm",!1,{description:"Cancel (without it, only the plan is printed)."});async execute(){let n=await this.caller();if(!this.confirm){let t=await n.query(x.jobs.getDetail,{jobId:this.jobId});if(t===null)throw new Error(`Job ${this.jobId} not found.`);return this.print({jobId:this.jobId,kind:t.kind,status:t.status,canceled:!1},r=>[{key:"would cancel",value:`${r.jobId} (${r.kind}, ${r.status})`},{key:"next",value:"re-run with --confirm"}]),0}return await n.mutation(x.jobs.cancel,{jobId:this.jobId}),this.print({canceled:this.jobId}),0}},Cb=class extends D{static{s(this,"WorkersLogsCommand")}static paths=[["platform","workers","logs"],["workers","logs"]];static usage=$.Usage({category:"Platform",description:"Tail one worker's captured stdout/stderr."});workerId=f.String({required:!0});limit=f.String("--limit",{description:"Max lines (default 500, max 2000)."});async execute(){let t=await(await this.caller()).query(x.workers.tailLog,{workerId:this.workerId,...this.limit?{limit:Number(this.limit)}:{}});return this.print(t,r=>r.map(i=>({at:Mb(i.at),stream:i.stream,text:i.text})),["at","stream","text"]),0}},Db=class extends D{static{s(this,"WorkersReaperStatusCommand")}static paths=[["platform","workers","reaper-status"],["workers","reaper-status"]];static usage=$.Usage({category:"Platform",description:"Show the last worker-reaper tick (confirm the cron is firing)."});async execute(){let t=await(await this.caller()).query(x.workers.reaperStatus,{});return t===null?(this.print({reaper:"no tick recorded yet"}),0):(this.print({...t,ranAt:Mb(t.ranAt)}),0)}},Fb=class extends D{static{s(this,"WorkersReapCommand")}static paths=[["platform","workers","reap"],["workers","reap"]];static usage=$.Usage({category:"Platform",description:"Force a reaper pass NOW (free dead leases / fail stalled jobs)."});async execute(){let t=await(await this.caller()).mutation(x.workers.reap,{});return this.print(t),0}},Lb=class extends D{static{s(this,"ImportsCleanupOrphansCommand")}static paths=[["platform","imports","cleanup-orphaned"],["imports","cleanup-orphaned"]];static usage=$.Usage({category:"Imports",description:"Find/fail orphaned import runs (status 'running' with no active job). Dry-run unless --confirm."});allTenants=f.Boolean("--all-tenants",!1,{description:"Scan every tenant (default: the active --tenant only)."});confirm=f.Boolean("--confirm",!1,{description:"Actually mark orphans failed (default: dry-run preview)."});async execute(){let n=await this.caller(),t=this.allTenants?void 0:this.requireTenant(n),r=await n.mutation(x.imports.failOrphanedRuns,{...t?{tenantSlug:t}:{},confirm:this.confirm});return this.print(r,i=>i.orphans.map(o=>({id:o.id,tenant:o.tenantSlug,importRunId:o.importRunId,phase:o.phase??"",updated:PF(o.updatedAt),action:i.confirmed?"failed":"would-fail"})),["id","tenant","importRunId","phase","updated","action"]),0}},NF=[Ob,Pb,Nb,_b,Cb,Db,Fb,Lb];var $6=/^(\d+)([mhd])$/,R6={m:6e4,h:36e5,d:864e5};function sm(e,n=Date.now()){let t=e.trim(),r=$6.exec(t);if(r!==null)return n-Number(r[1])*R6[r[2]];let i=/^\d{4}-\d{2}-\d{2}/.test(t)?Date.parse(t):Number.NaN;if(Number.isNaN(i))throw new Error(`--since "${e}": expected 90m, 24h, 2d or an ISO date like 2026-10-13T11:40Z`);return i}s(sm,"parseSince");function am(e){return e==null?"":new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z")}s(am,"ts");function Jb(e,n){if(e===void 0)throw new Error(`notifications ${n}: --locale is required (${We.join("|")}) \u2014 every letter exists in each language, and each is worded on its own`);if(!Kp(e))throw new Error(`notifications: --locale "${e}" is not a supported locale (${We.join("|")})`);return e}s(Jb,"parseLocale");function I6(e,n){let t={},r=s((i,o,a)=>{let l=o.indexOf("=");if(l<=0)throw new Error(`notifications letters: malformed ${i} "${o}" (expected <blockKey>=<value>)`);let d=o.slice(0,l).trim();if(!d)throw new Error(`notifications letters: malformed ${i} "${o}" (empty block key)`);if(d in t)throw new Error(`notifications letters: block "${d}" given twice \u2014 one value per block.`);t[d]=a(o.slice(l+1))},"put");for(let i of e??[])r("--slot",i,o=>o);for(let i of n??[])r("--slot-file",i,o=>he(o.trim(),"utf8"));return t}s(I6,"parseSlots");var qb=class extends D{static{s(this,"NotificationsListCommand")}static paths=[["platform","notifications","list"],["notifications","list"]];static usage=$.Usage({category:"Notifications",description:"List mail deliveries newest-first (platform-admin). Filter by --status, --template, --to, --since; the smtp column is the relay's answer (`250 \u2026 queued as <id>` = accepted).",examples:[["Dead-letters only","$0 notifications list --status dead"],["Everything still in flight","$0 notifications list --status queued"],["Did the login-page link to this address go out today?","$0 notifications list --template account.loginLink --to steffi@schule.example --since 24h"]]});status=f.String("--status",{description:"queued | sending | sent | skipped | dead"});template=f.String("--template",{description:"Only this letter, e.g. account.loginLink."});to=f.String("--to",{description:"Only deliveries to this address."});since=f.String("--since",{description:"Created since: 90m, 24h, 2d or an ISO date/time."});limit=f.String("--limit",{description:"Max rows (default 100)."});all=f.Boolean("--all",!1,{description:"Fetch every page (ignores --limit)."});async execute(){let n=await this.caller(),t=this.all?void 0:Gu(this.limit,100),r=await this.paginate(n,x.notifications.listPage,{...this.status?{status:this.status}:{},...this.template?{templateId:this.template}:{},...this.to?{recipientEmail:this.to}:{},...this.since?{since:sm(this.since)}:{}},{max:t,pageSize:Math.min(t??100,100)});return this.print(r,i=>i.map(o=>({id:o.id,template:o.templateId,status:o.status,tenant:o.tenantSlug??"",to:o.recipientEmail,files:o.attachmentCount>0?String(o.attachmentCount):"",tries:`${o.attempts}/${o.maxAttempts}`,error:o.errorCode??"",mode:o.transportMode??"",dup:o.possibleDuplicate?"!":"",created:am(o.createdAt),settled:am(o.settledAt),smtp:o.lastSmtpResponse??""})),["id","template","status","tenant","to","files","tries","error","mode","dup","created","settled","smtp"]),0}};function O6(e){if(e.letter===null)return{...e,attachments:[]};let{attachments:n,...t}=e.letter;return{...e,attachments:n.map(({filename:r,contentType:i,size:o})=>({filename:r,contentType:i,size:o})),letter:t}}s(O6,"showView");var Kb=class extends D{static{s(this,"NotificationsShowCommand")}static paths=[["platform","notifications","show"],["notifications","show"]];static usage=$.Usage({category:"Notifications",description:"Show one delivery in full: SMTP evidence, lease, sweeper bookkeeping, template summary."});deliveryId=f.String({required:!0});async execute(){let t=await(await this.caller()).query(x.notifications.getDetail,{deliveryId:this.deliveryId});if(t===null)throw new Error(`Delivery ${this.deliveryId} not found.`);return this.print(O6(t)),0}},jb=class extends D{static{s(this,"NotificationsRetryCommand")}static paths=[["platform","notifications","retry"],["notifications","retry"]];static usage=$.Usage({category:"Notifications",description:"Retry a DEAD delivery: a fresh attempt through the normal claim path. Check `show` first \u2014 a `possibleDuplicate` row may already have reached the recipient."});deliveryId=f.String({required:!0});async execute(){return await(await this.caller()).mutation(x.notifications.retry,{deliveryId:this.deliveryId}),this.print({deliveryId:this.deliveryId,status:"queued"}),0}},Bb=class extends D{static{s(this,"NotificationsSweeperStatusCommand")}static paths=[["platform","notifications","sweeper-status"],["notifications","sweeper-status"]];static usage=$.Usage({category:"Notifications",description:"Last tick of the notification sweeper cron (deadLastHour is the number to watch)."});async execute(){let t=await(await this.caller()).query(x.notifications.sweeperStatus,{});return t===null?(this.print({ranAt:null,note:"sweeper has not run since deploy"}),0):(this.print({...t,ranAt:am(t.ranAt),lastDeadAt:am(t.lastDeadAt)}),0)}},Vb=class extends D{static{s(this,"NotificationsSelfTestCommand")}static paths=[["platform","notifications","self-test"],["notifications","self-test"]];static usage=$.Usage({category:"Notifications",description:"Resolve the deployment's mail config, verify the SMTP connection + credentials, and send ONE test mail to --to with the raw SMTP transcript. A redirect deployment redirects the test too; dry sends nothing.",examples:[["Probe staging","$0 --env staging notifications self-test --to you@example.com"]]});to=f.String("--to",{required:!0,description:"Explicit recipient (never defaulted)."});async execute(){let t=await(await this.caller()).action(x.notificationActions.selfTest,{recipient:this.to});return this.print(t),t.ok?0:1}},Ub=class extends D{static{s(this,"NotificationsLettersListCommand")}static paths=[["notifications","letters","list"]];static usage=$.Usage({category:"Notifications",description:"The letter catalog for one school: what it can reword, and what it already did.",details:"Only the letters a school may actually write are listed \u2014 addressed to families, and with blocks to rewrite. A staff-internal letter or a retired one is not offered at all. `reworded` names the languages in which this school has already deviated from a letter.",examples:[["The catalog","$0 --tenant test notifications letters list"],["Only the reworded ones","$0 --tenant test notifications letters list --json"]]});async execute(){let n=await this.caller(),t=await n.query(x.notifications.letterWorkspace,{tenantSlug:this.requireTenant(n),locale:"de"});return this.print(t.letters,r=>r.map(i=>({template:i.id,label:i.label,blocks:i.slots.map(o=>o.key).join(", "),reworded:i.rewordedIn.join(", ")})),["template","label","blocks","reworded"]),0}},Gb=class extends D{static{s(this,"NotificationsLettersShowCommand")}static paths=[["notifications","letters","show"]];static usage=$.Usage({category:"Notifications",description:"One letter block by block: the current text, whether it deviates, and the placeholders it may use.",examples:[["The welcome letter","$0 --tenant test notifications letters show applicant.welcome --locale de"],["Its English version","$0 --tenant test notifications letters show applicant.welcome --locale en"]]});templateId=f.String({required:!0});locale=f.String("--locale",{description:`Letter language (${We.join("|")}) \u2014 required; each language is worded on its own`});async execute(){let n=await this.caller(),t=await n.query(x.notifications.letterWorkspace,{tenantSlug:this.requireTenant(n),locale:Jb(this.locale,"letters show")}),r=t.letters.find(i=>i.id===this.templateId);if(r===void 0)throw new Error(`notifications letters show: "${this.templateId}" is not a letter this school may reword \u2014 known: ${t.letters.map(i=>i.id).join(", ")}`);if(!this.json){let i=r.placeholders.map(o=>`{{${o.key}}}${o.required?" (Pflicht)":""}`).join(", ");this.context.stdout.write(`${r.label} \u2014 ${r.occasion.de}
|
|
11253
11256
|
Platzhalter: ${i||"\u2014"}
|
|
11254
11257
|
|
|
11255
|
-
`)}return this.print(r,i=>i.slots.map(o=>{let a=i.override?.[o.key];return{block:o.key,label:o.label,deviates:a===void 0?"":"yes",text:(a??o.default).replace(/\s+/g," ").slice(0,80)}}),["block","label","deviates","text"]),0}},zb=class extends D{static{s(this,"NotificationsLettersSetCommand")}static paths=[["notifications","letters","set"]];static usage=$.Usage({category:"Notifications",description:"Reword one or more blocks of a letter for this school (merge \u2014 untouched blocks stay as they are).",details:"A block whose text EQUALS the platform default is dropped rather than stored: what is kept is the deviation, never a copy, so a later improvement to an untouched block still reaches this school. An unknown block or an undeclared {{placeholder}} is refused by the backend with every finding named \u2014 nothing is written.",examples:[["One paragraph",'$0 --tenant test notifications letters set applicant.welcome --locale de --slot intro="Sch\xF6n, dass Sie da sind."'],["The English letter",'$0 --tenant test notifications letters set applicant.welcome --locale en --slot intro="Lovely to have you."'],["From a file","$0 --tenant test notifications letters set applicant.tasksOpen --locale de --slot-file intro=./intro.txt"]]});templateId=f.String({required:!0});locale=f.String("--locale",{description:`Letter language (${We.join("|")}) \u2014 required; each language is worded on its own`});slot=f.Array("--slot",{description:"<blockKey>=<text> (repeatable)"});slotFile=f.Array("--slot-file",{description:"<blockKey>=<path> \u2014 read the text from a local file (repeatable)"});async execute(){let n=I4(this.slot,this.slotFile);if(Object.keys(n).length===0)throw new Error("notifications letters set: nothing to write \u2014 pass --slot <blockKey>=<text> or --slot-file <blockKey>=<path>");let t=await this.caller(),r=await t.mutation(x.notifications.saveLetterOverride,{tenantSlug:this.requireTenant(t),templateId:this.templateId,locale:Jb(this.locale,"letters set"),slots:n});return this.print({templateId:this.templateId,submitted:Object.keys(n),...r},i=>[{key:"letter",value:i.templateId},{key:"submitted",value:i.submitted.join(", ")},{key:"deviating blocks",value:i.overriddenSlotKeys.join(", ")||"\u2014 (back to the platform text)"}]),0}},Wb=class extends D{static{s(this,"NotificationsLettersResetCommand")}static paths=[["notifications","letters","reset"]];static usage=$.Usage({category:"Notifications",description:"Drop this school's deviations \u2014 named blocks, or the whole letter with --all.",details:"--all is required to drop a whole letter: dropping everything must be typed, never be what happens when a --slot is forgotten.",examples:[["One block back to the platform text","$0 --tenant test notifications letters reset applicant.welcome --locale de --slot intro"],["The whole letter","$0 --tenant test notifications letters reset applicant.welcome --locale en --all"]]});templateId=f.String({required:!0});locale=f.String("--locale",{description:`Letter language (${We.join("|")}) \u2014 required; each language is worded on its own`});slot=f.Array("--slot",{description:"Block key to reset (repeatable)"});all=f.Boolean("--all",!1,{description:"Reset every block of this letter"});async execute(){let n=(this.slot??[]).map(i=>i.trim()).filter(Boolean);if(this.all&&n.length>0)throw new Error("notifications letters reset: --all resets everything \u2014 it cannot be combined with --slot.");if(!this.all&&n.length===0)throw new Error("notifications letters reset: name the blocks with --slot <blockKey>, or pass --all to reset the whole letter.");let t=await this.caller(),r=await t.mutation(x.notifications.resetLetterOverride,{tenantSlug:this.requireTenant(t),templateId:this.templateId,locale:Jb(this.locale,"letters reset"),...this.all?{}:{slotKeys:n}});return this.print({templateId:this.templateId,reset:this.all?"all":n.join(", "),...r},i=>[{key:"letter",value:i.templateId},{key:"reset",value:i.reset},{key:"still deviating",value:i.overriddenSlotKeys.join(", ")||"\u2014 (nothing)"}]),0}},$d=s((e,n)=>e==null?n:e.replace(/\s*\n\s*/g," \u23CE "),"flatCell");function lm(e,n,t){return["de","en"].map(r=>({field:`${e} (${r})`,school:n===null?"\u2014 (platform)":n[r]===""?"\u2014 (untranslated)":$d(n[r],""),...t===null?{}:{platform:$d(t[r],"")}}))}s(lm,"chromeTextRows");var Yb=class extends D{static{s(this,"NotificationsChromeShowCommand")}static paths=[["notifications","chrome","show"]];static usage=$.Usage({category:"Notifications",description:"The school's letter frame (greeting and sign-off per language, sender name) and the platform wording each falls back to."});async execute(){let n=await this.caller(),t=await n.query(x.notifications.getTenantChrome,{tenantSlug:this.requireTenant(n)});return this.print(t,r=>[...lm("greeting",r.greeting,r.defaults.greeting),...lm("closing",r.closing,r.defaults.closing),{field:"senderName",school:$d(r.senderName,"\u2014 (platform)"),platform:$d(r.defaults.senderName,"")}],["field","school","platform"]),0}},Hb=class extends D{static{s(this,"NotificationsChromeSetCommand")}static paths=[["notifications","chrome","set"]];static usage=$.Usage({category:"Notifications",description:"Set the school's letter frame. Greeting and sign-off are set in BOTH languages at once; both EMPTY clears that field back to the platform wording.",examples:[["Own sign-off",'$0 --tenant test notifications chrome set --closing-de="Herzliche Gr\xFC\xDFe, Ihr Grundschul-Team" --closing-en="Warm regards, your primary school team"'],["Back to the platform sign-off",'$0 --tenant test notifications chrome set --closing-de="" --closing-en=""']]});greetingDe=f.String("--greeting-de",{description:"Opening line, German"});greetingEn=f.String("--greeting-en",{description:"Opening line, English"});closingDe=f.String("--closing-de",{description:"Sign-off, German"});closingEn=f.String("--closing-en",{description:"Sign-off, English"});senderName=f.String("--sender-name",{description:"Name the school signs with (empty string clears it)"});async execute(){let n=s((l,d,c)=>{if(!(d===void 0&&c===void 0)){if(d===void 0||c===void 0)throw new Error(`notifications chrome set: --${l}-de and --${l}-en go together \u2014 the frame is worded in every language`);return{de:d,en:c}}},"pair"),t=n("greeting",this.greetingDe,this.greetingEn),r=n("closing",this.closingDe,this.closingEn);if(t===void 0&&r===void 0&&this.senderName===void 0)throw new Error("notifications chrome set: nothing to change \u2014 pass --greeting-de/--greeting-en, --closing-de/--closing-en or --sender-name");let i=await this.caller(),o=this.requireTenant(i);await i.mutation(x.notifications.saveTenantChrome,{tenantSlug:o,...t!==void 0?{greeting:t}:{},...r!==void 0?{closing:r}:{},...this.senderName!==void 0?{senderName:this.senderName}:{}});let a=await i.query(x.notifications.getTenantChrome,{tenantSlug:o});return this.print(a,l=>[...lm("greeting",l.greeting,null),...lm("closing",l.closing,null),{field:"senderName",school:$d(l.senderName,"\u2014 (platform)")}],["field","school"]),0}},_F=[qb,Kb,jb,Bb,Vb,Ub,Gb,zb,Wb,Yb,Hb];var P4="-stufe-",N4=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function Qb(e){return`${e}${P4}`}s(Qb,"stageKeyPrefix");function Zb(e,n){return`${Qb(e)}${n}`}s(Zb,"stageStorageKey");function DF(e,n){let t=Qb(e);return n.startsWith(t)&&n.length>t.length}s(DF,"isUnderProgram");function Vr(e,n){let t=Qb(e);return DF(e,n)||le("CONFLICT",{de:`[stage/foreignKey] Der Stufenschl\xFCssel \u201E${n}\u201C liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${t}<key>\u201C). F\xFChren Sie die Stufe in bundle.yaml unter einem neuen Schl\xFCssel auf; der n\xE4chste Apply archiviert diese Zeile (hinter der Archivsperre) und legt die Stufe mit dem neuen Schl\xFCssel an.`,en:`[stage/foreignKey] The level key "${n}" is not under the program "${e}" (expected: "${t}<key>"). List the level in bundle.yaml under a new key; the next apply archives this row (behind the archive lock) and creates the level with the new key.`}),n.slice(t.length)}s(Vr,"bareStageKey");function dm(e){let n=[],t=new Map;return e.forEach((r,i)=>{let o=Rn(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.stages[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?n.push({code:"stage/nameMissing",index:i,message:{de:`[stage/nameMissing] ${l}: jede Klassenstufe braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[stage/nameMissing] ${l}: every stage needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&n.push({code:"stage/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){n.push({code:"stage/keyMissing",index:i,message:{de:`[stage/keyMissing] ${l}: jede Klassenstufe braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[stage/keyMissing] ${l}: every stage needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!N4.test(d)){n.push({code:"stage/keyInvalid",index:i,message:{de:`[stage/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[stage/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=t.get(d);if(c!==void 0){n.push({code:"stage/duplicateKey",index:i,message:{de:`[stage/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.stages[${c}] verwendet`,en:`[stage/duplicateKey] ${l}: key "${d}" is already used by program.stages[${c}]`}});return}t.set(d,i)}),n}s(dm,"stageSpecIssues");function CF(e){return{de:e.de.trim(),en:e.en.trim()}}s(CF,"trimmedText");function _4(e,n){let t=[];return e.de!==n.de&&t.push(`"${e.de}" \u2192 "${n.de}"`),e.en!==n.en&&t.push(`en "${e.en}" \u2192 "${n.en}"`),t.join(", ")}s(_4,"describeNameChange");function cm(e,n,t){if(e===null)return n.length>0&&F("planStageReconcile: stages exist but the offer has no program key"),t.map((a,l)=>({op:"insert",key:a.key,name:CF(a.name),...a.gradeLevel!==void 0?{gradeLevel:a.gradeLevel}:{},sequence:l+1}));let r=new Map(n.map(a=>[a.key,a])),i=new Set,o=[];t.forEach(({name:a,...l},d)=>{let c={...l,name:CF(a)},u=Zb(e,c.key);i.add(u);let p=d+1,m=r.get(u);if(m===void 0){o.push({op:"insert",key:c.key,name:c.name,...c.gradeLevel!==void 0?{gradeLevel:c.gradeLevel}:{},sequence:p});return}let y={};hs(m.name,c.name)||(y.name=[m.name,c.name]);let k=m.gradeLevel??null,g=c.gradeLevel??null;k!==g&&(y.gradeLevel=[k,g]),m.sequence!==p&&(y.sequence=[m.sequence,p]),(Object.keys(y).length>0||m.archived)&&o.push({op:"update",key:c.key,stageId:m.stageId,name:c.name,changes:y,unarchive:m.archived})});for(let a of[...n].sort((l,d)=>l.sequence-d.sequence))a.archived||i.has(a.key)||o.push({op:"archive",key:DF(e,a.key)?Vr(e,a.key):a.key,stageId:a.stageId,name:a.name});return o}s(cm,"planStageReconcile");function um(e){switch(e.op){case"insert":return`+stage ${e.key} (${e.name.de})`;case"archive":{let n=e.occupancy,t=[...n&&n.activeApplications>0?[`REFUSED: ${n.activeApplications} active application(s) \u2014 [stage/hasActiveApplications]`]:[],...n&&n.openLeads>0?[`${n.openLeads} open lead(s)`]:[]];return`-stage ${e.key} (${e.name.de})${t.length>0?` \u2014 ${t.join("; ")}`:""}`}case"update":{let n=[];if(e.unarchive&&n.push("restored"),e.changes.name&&n.push(_4(e.changes.name[0],e.changes.name[1])),e.changes.gradeLevel){let[t,r]=e.changes.gradeLevel;n.push(`grade ${t??"\u2013"} \u2192 ${r??"\u2013"}`)}return e.changes.sequence&&n.push(`position ${e.changes.sequence[0]} \u2192 ${e.changes.sequence[1]}`),`~stage ${e.key} (${n.join(", ")})`}}}s(um,"describeStageStep");var C4=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function pi(e,n){return`${e}-${n}`}s(pi,"runStorageKey");function FF(e,n){typeof n!="string"&&le("CONFLICT",{de:`[run/keyNotServed] Das Deployment liefert f\xFCr ein Schuljahr von \u201E${e}\u201C keinen Schl\xFCssel \u2014 es l\xE4uft ein \xE4lteres Release als die CLI. Nach dem n\xE4chsten Release erneut versuchen.`,en:`[run/keyNotServed] The deployment provides no key for a school year of "${e}" \u2014 it runs an older release than the CLI. Try again after the next release.`});let t=`${e}-`;return(!n.startsWith(t)||n.length===t.length)&&le("CONFLICT",{de:`[run/foreignKey] Der Schl\xFCssel \u201E${n}\u201C des Schuljahrs liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${t}<key>\u201C).`,en:`[run/foreignKey] The key "${n}" of the school year is not under the program "${e}" (expected: "${t}<key>").`}),n.slice(t.length)}s(FF,"bareRunKey");function fm(e){let n=[],t=new Map;return e.forEach((r,i)=>{let o=Rn(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.runs[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?n.push({code:"run/nameMissing",index:i,message:{de:`[run/nameMissing] ${l}: jedes Schuljahr braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[run/nameMissing] ${l}: every run needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&n.push({code:"run/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){n.push({code:"run/keyMissing",index:i,message:{de:`[run/keyMissing] ${l}: jedes Schuljahr braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[run/keyMissing] ${l}: every run needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!C4.test(d)){n.push({code:"run/keyInvalid",index:i,message:{de:`[run/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[run/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=t.get(d);if(c!==void 0){n.push({code:"run/duplicateKey",index:i,message:{de:`[run/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.runs[${c}] verwendet`,en:`[run/duplicateKey] ${l}: key "${d}" is already used by program.runs[${c}]`}});return}t.set(d,i)}),n}s(fm,"runSpecIssues");var D4={capacity:null,isOpen:!1},F4={capacity:null,isOpen:!0};function L4(e){return e===null||e==="unlimited"||typeof e=="number"&&Number.isInteger(e)&&e>=0}s(L4,"isCapacity");function pm(e,n){let t=[],r=n===void 0?void 0:new Set(n);return e.forEach((i,o)=>{if(i.capacities===void 0)return;let a=`program.runs[${o}] ("${i.key}")`;if(i.isOpen!==void 0&&t.push(`[capacity/runIsOpenWithCells] ${a}: \`isOpen\` on the run AND \`capacities\` \u2014 the open state lives on each cell; drop the run-level \`isOpen\``),i.capacities===null||typeof i.capacities!="object"||Array.isArray(i.capacities)){t.push(`[capacity/shape] ${a}: \`capacities\` must map stage keys to { isOpen, capacity }`);return}for(let[l,d]of Object.entries(i.capacities)){let c=`${a}.capacities.${l}`;r!==void 0&&!r.has(l)&&t.push(`[capacity/unknownStage] ${c}: no stage with key "${l}" in program.stages (have: ${[...r].join(", ")||"none"})`);let u=d;if(u===null||typeof u!="object"){t.push(`[capacity/shape] ${c}: expected { isOpen, capacity }`);continue}typeof u.isOpen!="boolean"&&t.push(`[capacity/isOpen] ${c}: \`isOpen\` must be true or false`),(!("capacity"in u)||!L4(u.capacity))&&t.push(`[capacity/value] ${c}: \`capacity\` must be a whole number \u2265 0, "unlimited", or null (unconfigured) \u2014 got ${JSON.stringify(u.capacity)}`)}}),t}s(pm,"capacitySpecIssues");function MF(e,n,t={stageKeys:[],runKeys:[]}){let r=e.programKey,i=new Map;if(r!==null)for(let c of e.stages)c.archived||i.set(Vr(r,c.key),c.stageId);let o=new Set(t.stageKeys),a=new Set(t.runKeys),l=new Map(e.runStages.map(c=>[`${c.runId}|${c.stageId}`,c])),d=[];for(let c of n){if(c.capacities===void 0)continue;let u=r===null?void 0:e.runs.find(p=>p.key===pi(r,c.key));if(u===void 0&&!a.has(c.key))throw new Error(`offer[admission]: run "${c.key}" does not exist and is not created by this apply`);for(let[p,m]of Object.entries(c.capacities)){let y=i.get(p);if(y===void 0&&!o.has(p))throw new Error(`offer[admission]: capacities of run "${c.key}" name stage "${p}", which the program does not have (have: ${[...i.keys()].join(", ")||"none"})`);let k={capacity:m.capacity,isOpen:m.isOpen},g=u!==void 0&&y!==void 0?l.get(`${u.runId}|${y}`):void 0,v=g!==void 0?{capacity:g.capacity,isOpen:g.isOpen}:u===void 0?D4:F4;v.capacity===k.capacity&&v.isOpen===k.isOpen||d.push({run:c.key,stageKey:p,from:v,to:k})}}return d}s(MF,"planRunCapacities");function LF(e){return`${e.capacity===null?"unconfigured":String(e.capacity)}/${e.isOpen?"open":"closed"}`}s(LF,"describeCell");function mm(e){return`~cap ${e.run}\xD7${e.stageKey} ${LF(e.from)} \u2192 ${LF(e.to)}`}s(mm,"describeCapacityStep");function qF(e){if(e.programKey===void 0)throw new Error("offer[admission]: the target backend predates stage keys \u2014 deploy it before running offer plan / apply / export with this CLI")}s(qF,"assertBackendHasStageKeys");async function Xb(e,n,t,r){let i=await e.query(x.programAdmin.getAngebotConfig,{client:n,offerKey:t,includeArchived:!0}),o=i.stages.map(u=>({stageId:u.stageId,key:u.key,name:u.name,...u.gradeLevel!==void 0?{gradeLevel:u.gradeLevel}:{},sequence:u.sequence,archived:u.archived}));qF(i);let a=cm(i.programKey,o,r),l=a.flatMap(u=>u.op==="archive"?[u.stageId]:[]);if(l.length===0)return a;let d=await e.query(x.programAdmin.getStageOccupancy,{client:n,offerKey:t,stageIds:l}),c=new Map(d.map(u=>[u.stageId,u]));return a.map(u=>{if(u.op!=="archive")return u;let p=c.get(u.stageId);if(p===void 0)throw new Error(`offer[admission]: no occupancy returned for stage ${u.stageId}`);return{...u,occupancy:{activeApplications:p.activeApplications,openLeads:p.openLeads}}})}s(Xb,"planStages");async function hm(e,n,t,r){let i=r.program?.runs??[];if(!i.some(c=>c.capacities!==void 0))return[];let o=t===null?{programKey:null,stages:[],runs:[],runStages:[]}:await e.query(x.programAdmin.getAngebotConfig,{client:n,offerKey:t});qF(o);let a=new Set(o.programKey===null?[]:o.stages.map(c=>Vr(o.programKey,c.key))),l=r.program?.stages?.map(c=>c.key)??[],d=o.programKey;return MF(o,i,{stageKeys:l.filter(c=>!a.has(c)),runKeys:i.map(c=>c.key).filter(c=>d===null||!o.runs.some(u=>u.key===pi(d,c)))})}s(hm,"planCapacities");async function M4(e,n,t,r){let i=(r.program?.runs??[]).map(d=>d.key);if(i.length===0)return;let o=await e.query(x.programAdmin.getAngebotConfig,{client:n,offerKey:t,includeArchived:!0}),a=o.programKey;if(a===null)return;let l=i.filter(d=>o.runs.some(c=>c.key===pi(a,d)&&c.status==="archived"));if(l.length>0)throw new Error(`offer[admission]: run(s) ${l.map(d=>`"${d}"`).join(", ")} exist only ARCHIVED \u2014 restore with \`offer run restore --run <key>\` or drop the bundle entry`)}s(M4,"assertNoArchivedRunKey");var ev={name:"admission",async scaffold(e,n,t,r){let i=t.tenant,o=t.program?.stages,a=[...dm(o??[]),...fm(t.program?.runs??[])];if(a.length>0)throw new Error(`offer[admission]: ${a.map(g=>g.message.de).join("; ")}`);let l=pm(t.program?.runs??[],o?.map(g=>g.key));if(l.length>0)throw new Error(`offer[admission]: ${l.join("; ")}`);await M4(e,i,n,t);let d=await hm(e,i,n,t),c=await e.query(x.programAdmin.getAngebotConfig,{client:i,offerKey:n}),u=q4(t);if(!u)throw new Error("offer[admission]: no unit to link \u2014 set links.unitKey or program.unitKey in bundle.yaml");let p=c.units.find(g=>g.key===u);if(!p)throw new Error(`offer[admission]: unit "${u}" not found in tenant "${i}". Available keys: ${c.units.flatMap(g=>g.key===null?[]:[g.key]).join(", ")||"(none)"}`);let m=[];if(r.dryRun||(await e.mutation(x.programAdmin.ensurePedagogyUnit,{client:i,unitId:p.unitId}),await e.mutation(x.programAdmin.createProgramForAngebot,{client:i,offerKey:n,unitId:p.unitId,...t.program?.key!==void 0?{programKey:t.program.key}:{}})),m.push(`unit=${u}`),o!==void 0)if(r.dryRun){let g=await Xb(e,i,n,o);m.push(...g.map(um))}else{let g=await e.mutation(x.programAdmin.reconcileProgramStages,{client:i,offerKey:n,stages:o.map(v=>({key:v.key,name:v.name,...v.gradeLevel!==void 0?{gradeLevel:v.gradeLevel}:{}}))});m.push(...g.steps,...g.warnings.map(v=>`warning ${v}`))}let y=r.dryRun?c:await e.query(x.programAdmin.getAngebotConfig,{client:i,offerKey:n});for(let g of t.program?.runs??[]){let v=y.programKey===null?void 0:y.runs.find(E=>E.key===pi(y.programKey,g.key));if(v!==void 0){hs(v.name,g.name)||(r.dryRun||await e.mutation(x.programAdmin.updateProgramRun,{client:i,offerKey:n,runId:v.runId,name:g.name}),m.push(`~run ${g.key} ("${_e(v.name)}" \u2192 "${_e(g.name)}")`));continue}r.dryRun||await e.mutation(x.programAdmin.addProgramRun,{client:i,offerKey:n,key:g.key,name:g.name,isOpen:g.capacities!==void 0?!1:g.isOpen??!0,...g.startDate?{startDate:g.startDate}:{},...g.endDate?{endDate:g.endDate}:{}}),m.push(`+run ${g.key} (${_e(g.name)})`)}let k=r.dryRun?d:await hm(e,i,n,t);if(!r.dryRun&&k.length>0){let g=await e.query(x.programAdmin.getAngebotConfig,{client:i,offerKey:n}),v=g.programKey;if(v===null)throw new Error("offer[admission]: capacities need a program \u2014 none was linked");for(let E of k){let A=g.runs.find(_=>_.key===pi(v,E.run))?.runId,I=g.stages.find(_=>Vr(v,_.key)===E.stageKey)?.stageId;if(A===void 0||I===void 0)throw new Error(`offer[admission]: cell ${E.run}\xD7${E.stageKey} vanished between plan and write`);await e.mutation(x.programAdmin.setRunStageCapacity,{client:i,offerKey:n,runId:A,stageId:I,capacity:E.to.capacity,isOpen:E.to.isOpen})}}return m.push(...k.map(mm)),m.join(", ")}};function q4(e){let n=e.program?.unitKey,t=e.links?.unitKey;if(n!==void 0&&t!==void 0&&n!==t)throw new Error(`offer[admission]: bundle.yaml names two units \u2014 program.unitKey "${n}" and links.unitKey "${t}"; keep one`);return n??t}s(q4,"bundleUnitKey");var KF={role:"control",effect:"pure",cardinality:"N-to-1"};var gm=["add","remove","replace"];function jF(e,n){let t=e.inputs?.[n];if(!(!t||t.kind!=="literal"))return t.value!=null?String(t.value):void 0}s(jF,"roleAssignLiteral");var BF={role:"method",effect:"context-mutation",inputs:s(()=>[{id:"person",label:{de:"Person",en:"Person"},type:"personRef",required:!0},{id:"roleKey",label:{de:"Rolle",en:"Role"},type:"roleKey",required:!0,optionSource:"tenantRoles"},{id:"mode",label:{de:"Modus",en:"Mode"},type:"enum",defaultValue:"add",optionSource:"declared",enumOptions:[{value:"add",label:{de:"Rolle hinzuf\xFCgen",en:"Add role"}},{value:"remove",label:{de:"Rolle entziehen",en:"Remove role"}},{value:"replace",label:{de:"Alle Rollen ersetzen",en:"Replace all roles"}}]}],"inputs"),validate:s((e,n,t)=>{let r=[],i=jF(e,"roleKey")?.trim()??"",o=jF(e,"mode")??"add";return i===""?r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.roleKey`,reason:{de:`[roleAssign/missingRoleKey] roleAssign-Knoten "${e.id}" nennt keine Rolle \u2014 welche Rolle vergeben wird, muss der Autor aus dem Rollenkatalog des Mandanten w\xE4hlen.`,en:`[roleAssign/missingRoleKey] roleAssign node "${e.id}" names no role \u2014 the author must choose which role is assigned from the school's role catalog.`},severity:"error"}):t?.roleKeys!==void 0&&!t.roleKeys.has(i)?r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.roleKey`,reason:{de:`[roleAssign/unknownRoleKey] Rolle "${i}" existiert nicht im Rollenkatalog des Mandanten \u2014 der Knoten w\xFCrde bei jeder Ausf\xFChrung abbrechen. Bekannte Rollen: ${[...t.roleKeys].sort().join(", ")}.`,en:`[roleAssign/unknownRoleKey] Role "${i}" does not exist in the school's role catalog \u2014 the node would abort on every run. Known roles: ${[...t.roleKeys].sort().join(", ")}.`},severity:"error"}):t?.assignableRoleKeys!==void 0&&!t.assignableRoleKeys.has(i)&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.roleKey`,reason:{de:`[roleAssign/nonLeafRoleKey] Rolle "${i}" hat untergeordnete Rollen und ist deshalb nicht vergebbar \u2014 eine Partei bekommt ein Blatt, keine Oberkategorie. Vergebbare Rollen: ${[...t.assignableRoleKeys].sort().join(", ")}.`,en:`[roleAssign/nonLeafRoleKey] Role "${i}" has sub-roles and therefore cannot be assigned \u2014 a party gets a leaf role, not a parent category. Assignable roles: ${[...t.assignableRoleKeys].sort().join(", ")}.`},severity:"error"}),gm.includes(o)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.mode`,reason:{de:`[roleAssign/unknownMode] roleAssign-Knoten "${e.id}" deklariert Modus "${o}" \u2014 erlaubt sind ${gm.join(" | ")}.`,en:`[roleAssign/unknownMode] roleAssign node "${e.id}" declares mode "${o}" \u2014 allowed are ${gm.join(" | ")}.`},severity:"error"}),r},"validate")};var K4=["event","effect","outcomes"],nv=s((e,n,t)=>({layer:"GRAPH",kind:"nodeRule",path:e,reason:{de:n,en:t},severity:"error"}),"issue"),VF={outcomes:[{id:mr,label:{de:"Gestartet",en:"Started"}}],validate:s((e,n)=>{let t=[],r=e;for(let i of K4)i in r&&t.push(nv(`nodes.${e.id}.${i}`,`[graph/retiredField] Start-Knoten "${e.id}": \`${i}\` gibt es nicht mehr \u2014 der Knotentyp deklariert seinen einen Ausgang \u201E${mr}" selbst.`,`[graph/retiredField] Start node "${e.id}": \`${i}\` no longer exists \u2014 the node type declares its one outcome "${mr}" itself.`));return Qt(n.nodes).some(i=>i.target===e.id)&&t.push(nv(`nodes.${e.id}`,`[eventTrigger/notStart] Knoten "${e.id}" ist ein Start-Knoten, hat aber eine eingehende Kante \u2014 nur der Start l\xF6st ihn aus, jeder Vorgang bliebe hier stehen.`,`[eventTrigger/notStart] Node "${e.id}" is a start node but has an incoming edge \u2014 only the start triggers it, every process would stop here.`)),e.next?.[mr]===void 0&&t.push(nv(`nodes.${e.id}.next.${mr}`,`[eventTrigger/unroutedStart] Start-Knoten "${e.id}" leitet \u201E${mr}" nirgendwohin.`,`[eventTrigger/unroutedStart] Start node "${e.id}" routes "${mr}" nowhere.`)),t},"validate")};var j4="submit",UF=[{id:j4,kind:"advance",label:{de:"Absenden",en:"Submit"},availableIn:["draft"]}];function GF(e){return e==="draft"}s(GF,"isWritableSmartFormState");var tv=["draft","committed"],nRe=tv.filter(e=>GF(e));async function zF(e,n,t){let r=await e.db.query("smart_form_instances").withIndex("by_applicationId_and_formNodeId",i=>i.eq("applicationId",n).eq("formNodeId",t)).take(2);return r.length>1&&F(`application ${n}: two form instances for node "${t}" (${r[0]._id}, ${r[1]._id}) \u2014 at most one may exist`),r[0]??null}s(zF,"getSmartFormInstance");var WF="form:fill",rv="request:collectPayment";var B4={key:WF,recipient:"external",title:{de:"Bewerbung ausf\xFCllen & absenden",en:"Complete & submit application"},unlocks:["submit"],advancesNode:!0},YF={key:"bearbeitung",label:te("In Bearbeitung","In progress"),scope:"node"},HF={[qR]:{label:te("In Bearbeitung","In progress"),tone:"neutral",phase:YF,external:en(te("Entwurf","Draft"),"neutral",te("Bewerbung fortsetzen","Continue application"),te("Sie haben die Bewerbung bereits begonnen. Schlie\xDFen Sie sie ab, um sie einzureichen.","You have already started the application. Complete it to submit it."),te("Bewerbung fortsetzen","Continue application"),"continue-form")},[Xu]:{label:te("Eingereicht","Submitted"),tone:"blue",phase:YF,external:en(te("Eingereicht","Submitted"),"blue",te("Ihre Bewerbung ist eingereicht","Your application has been submitted"),te("Ihre Bewerbung ist bei uns eingegangen. Wir melden uns mit den n\xE4chsten Schritten.","We have received your application. We will be in touch with the next steps."))}},JF={role:"user-action",effect:"side-effect",progressDefaults:HF,progressEvents:Mn(HF),actions:s(()=>UF,"actions"),workItemTemplates:s(()=>[B4],"workItemTemplates"),states:tv,currentState:s(async(e,n)=>{let t=await zF(e,n.applicationId,n.node.id);return t===null?"draft":t.state},"currentState"),inputs:s(e=>[{id:"smartForm",label:{de:"Formular",en:"Form"},type:"smartForm",optionSource:"offerSmartForms",required:e.adoptForm===void 0,inspector:"literal-only"}],"inputs"),outputs:s(e=>[{name:"admission",type:"admission",label:{de:"Anmeldung",en:"Application"},schema:[{key:"beneficiary",type:"personRef",label:{de:"Beschulte Person",en:"Student"}},{key:"signers",type:"personList",label:{de:"Unterzeichner",en:"Signers"}},...e.formExports??[]]}],"outputs"),notificationEvents:s(e=>vt(e)?[]:[{id:ef,label:{de:"Formular abgesendet",en:"Form submitted"},audience:"external",args:[{key:"applicationId",type:"string",required:!0}]}],"notificationEvents"),validate:s(e=>{let n=[],t=e.inputs?.smartForm,r=t?.kind==="literal"&&typeof t.value=="string"&&t.value.length>0,i=e.adoptForm!==void 0;return r&&i?n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.adoptForm`,reason:{de:`[form.adopt-xor-create] Form-Knoten "${e.id}" hat sowohl ein smartForm als auch adoptForm \u2014 genau eines ist erlaubt.`,en:`[form.adopt-xor-create] Form node "${e.id}" has both a smartForm and adoptForm \u2014 exactly one is allowed.`},severity:"error"}):!r&&!i&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.smartForm`,reason:{de:`[form.adopt-xor-create] Form-Knoten "${e.id}" braucht entweder ein smartForm (neu erzeugen) oder adoptForm (bestehende Instanz \xFCbernehmen).`,en:`[form.adopt-xor-create] Form node "${e.id}" needs either a smartForm (create new) or adoptForm (adopt an existing instance).`},severity:"error"}),n},"validate")};var QF={role:"system-action",effect:"side-effect",inputs:s(()=>[{id:On.target,label:{de:"Formular",en:"Form"},type:"admission",required:!0,inspector:"binding-only"},{id:On.flagKey,label:{de:"Merkmal im Formular",en:"Flag in the form"},type:"formFlag",required:!0,inspector:"literal-only",optionSource:"targetFormFlags"},{id:On.value,label:{de:"Setzen oder zur\xFCcknehmen",en:"Raise or lower"},type:"boolean",defaultValue:!0,inspector:"literal-only",enumOptions:[{value:"true",label:{de:"Setzen",en:"Raise"}},{value:"false",label:{de:"Zur\xFCcknehmen",en:"Lower"}}]}],"inputs"),notificationEvents:s(e=>[{id:"unlocked",label:{de:"Abschnitt freigeschaltet",en:"Section unlocked"},audience:"external",required:cO(e),args:[{key:"applicationId",type:"string",required:!0},{key:"sectionLabel",type:"localizedText",required:!0}]}],"notificationEvents"),validate:s(e=>{let n=[];e.inputs?.[On.flagKey]?.kind==="literal"&&xf(e)===null&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.${On.flagKey}`,reason:{de:`[setFlag/missingFlagKey] setFlag-Knoten "${e.id}" nennt kein Merkmal (Parameter \u201EMerkmal im Formular\u201C).`,en:`[setFlag/missingFlagKey] setFlag node "${e.id}" names no flag (parameter "Flag in the form").`},severity:"error"});let r=e.inputs?.[On.value];return r?.kind==="literal"&&typeof r.value!="boolean"&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.${On.value}`,reason:{de:`[setFlag/valueType] setFlag-Knoten "${e.id}": \u201ESetzen oder zur\xFCcknehmen\u201C ist ein Ja/Nein-Wert (true/false), kein Text.`,en:`[setFlag/valueType] setFlag node "${e.id}": "Raise or lower" is a yes/no value (true/false), not text.`},severity:"error"}),n},"validate")};var V4="true",U4="false",iv=[{id:V4,label:{de:"Ja",en:"Yes"}},{id:U4,label:{de:"Nein",en:"No"}}];var ZF={role:"control",effect:"pure",cardinality:"1-to-N",outcomes:iv,validate:s((e,n,t)=>G4(e,n,t),"validate")};function G4(e,n,t){let r=s(o=>({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.condition`,reason:{de:`[if/condition] Knoten "${e.id}": ${o.de}`,en:`[if/condition] Node "${e.id}": ${o.en}`},severity:"error"}),"issue"),i=iv.filter(o=>e.next?.[o.id]===void 0).map(o=>({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.next.${o.id}`,reason:{de:`[if/unroutedOutcome] Knoten "${e.id}": Ausgang \u201E${o.label.de}\u201C (${o.id}) f\xFChrt nirgendwohin.`,en:`[if/unroutedOutcome] Node "${e.id}": Outcome "${o.label.en}" (${o.id}) leads nowhere.`},severity:"error"}));return typeof e.condition!="string"||e.condition.trim()===""?[...i,r({de:"Bedingung fehlt.",en:"The condition is missing."})]:[...i,...tp(e.condition,nI(n),t).map(r)]}s(G4,"ifNodeIssues");var ga="decision",z4=new Set(["decision","review"]),ERe=new Set([...z4,"governedDocument"]);var eL=[{id:"approved",label:{de:"Freigeben",en:"Approve"},semantic:"granted"},{id:"rejected",label:{de:"Ablehnen",en:"Reject"},semantic:"rejected"},{id:"waitlisted",label:{de:"Auf Warteliste",en:"Waitlist"},semantic:"waitlisted"}],XF={released:{label:te("Freigegeben","Released"),tone:"green",phase:{key:"freigabe",label:te("Freigabe","Release"),scope:"node"},external:en(te("Freigegeben","Released"),"green",te("Ihre Bewerbung wurde freigegeben","Your application has been released"),te("Wir haben Ihre Bewerbung freigegeben und melden uns mit den n\xE4chsten Schritten.","We have released your application and will be in touch with the next steps."))}},Bo={role:"user-action",effect:"side-effect",outcomes:eL,progressDefaults:XF,progressEvents:Mn(XF),notificationEvents:s(e=>(e.outcomes??[]).map(n=>({id:n.id,label:n.label,audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"comment",type:"string"}]})),"notificationEvents"),actions:s(e=>[...(e.outcomes??[]).map(n=>({id:n.id,kind:"advance",outcome:n.id,label:n.label,...Ii(n.semantic)?{semantic:n.semantic}:{}})),...DN(e)],"actions"),optionalActionKinds:["spawnTasks"],workItemTemplates:s(e=>[{key:ga,recipient:"internal",title:e.decisionAsTask?.title??{de:"Entscheidung",en:"Decision"},unlocks:(e.outcomes??[]).map(n=>n.id).filter(n=>typeof n=="string"&&n.length>0),gatesNode:!1,advancesNode:!0,dueInDays:e.decisionAsTask?.dueInDays}],"workItemTemplates"),taskDocuments:s((e,n)=>n===ga&&Array.isArray(e.reads)?e.reads.map(t=>({kind:"field",address:t})):[],"taskDocuments"),taskFormView:s((e,n)=>n===ga?e.formView:void 0,"taskFormView"),validate:ov};function ov(e,n,t){let r=[],i=e.outcomes??[];i.length===0&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes`,reason:{de:`[decision/missingOutcomes] Entscheidungs-Knoten "${e.id}" hat keine Outcomes \u2014 die Entscheidung w\xE4re niemals aufl\xF6sbar.`,en:`[decision/missingOutcomes] Decision node "${e.id}" has no outcomes \u2014 the decision could never be resolved.`},severity:"error"});let o=new Set(i.map(l=>l.id));for(let l of i){let d=l.label;(typeof d=="string"?d.trim().length>0:d!=null&&typeof d=="object"&&Object.values(d).some(p=>typeof p=="string"&&p.trim().length>0))||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes.${l.id}`,reason:{de:`[decision/outcomeMissingLabel] Outcome "${l.id}" von "${e.id}" hat keine Beschriftung \u2014 sie ist der Text des Knopfs im Cockpit.`,en:`[decision/outcomeMissingLabel] Outcome "${l.id}" of "${e.id}" has no label \u2014 it is the text of the button in the cockpit.`},severity:"error"});let u=l.semantic;u===void 0?r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes.${l.id}.semantic`,reason:{de:`[decision/outcomeSemanticMissing] Outcome "${l.id}" von "${e.id}" sagt nicht, was es bedeutet \u2014 eines von ${bt.join(", ")}.`,en:`[decision/outcomeSemanticMissing] Outcome "${l.id}" of "${e.id}" does not say what it means \u2014 one of ${bt.join(", ")}.`},severity:"error"}):Ii(u)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes.${l.id}.semantic`,reason:{de:`[decision/outcomeSemanticUnknown] Outcome "${l.id}" von "${e.id}" hat die Bedeutung "${String(u)}" \u2014 erlaubt: ${bt.join(", ")}.`,en:`[decision/outcomeSemanticUnknown] Outcome "${l.id}" of "${e.id}" has the meaning "${String(u)}" \u2014 allowed: ${bt.join(", ")}.`},severity:"error"})}for(let l of Object.keys(e.commentRequired??{}))o.has(l)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.commentRequired.${l}`,reason:{de:`[decision/commentRequiredUnknownOutcome] Unbekanntes Outcome "${l}" in commentRequired; erlaubt: ${[...o].join(", ")}`,en:`[decision/commentRequiredUnknownOutcome] Unknown outcome "${l}" in commentRequired; allowed: ${[...o].join(", ")}`},severity:"error"});let a=e.decisionAsTask?.title;return a!==void 0&&(a!==null&&typeof a=="object"&&Object.values(a).some(d=>typeof d=="string"&&d.length>0)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.decisionAsTask.title`,reason:{de:"[decision/decisionTaskMissingTitle] decisionAsTask.title ist gesetzt, aber leer \u2014 entweder einen nicht-leeren lokalisierten Text angeben oder das Feld weglassen (dann greift der Standardtitel).",en:"[decision/decisionTaskMissingTitle] decisionAsTask.title is set but empty \u2014 either give a non-empty localized text or omit the field (the default title then applies)."},severity:"error"})),r}s(ov,"validateDecisionNode");var sv=[{id:"promoted",label:{de:"Nachger\xFCckt",en:"Moved up"}},{id:"closed",label:{de:"Warteliste geschlossen",en:"Waiting list closed"}}],nL=[{id:"complete",label:{de:"Vollst\xE4ndig",en:"Complete"}},{id:"acceptedIncomplete",label:{de:"Ohne Nachreichung abgeschlossen",en:"Closed without the missing documents"}},{id:"rejected",label:{de:"Abgelehnt",en:"Rejected"}},{id:"absage",label:{de:"Zur\xFCckgezogen",en:"Withdrawn"}}];var av="promoted";var tL="promote",rL="Nachr\xFCcken";var lv={key:"warteliste",label:te("Warteliste","Waitlist"),scope:"global",track:"parked",waitlist:!0},iL={waitlisted:{label:te("Warteliste","Waitlisted"),tone:"amber",phase:lv,external:en(te("Warteliste","Waiting list"),"amber",te("Sie stehen auf der Warteliste","You are on the waiting list"),te("Ihre Bewerbung wurde auf die Warteliste gesetzt. Wir informieren Sie, sobald ein Platz frei wird.","Your application has been placed on the waiting list. We will let you know as soon as a place becomes available."))},promoted:{label:te("Nachger\xFCckt","Promoted"),tone:"green",phase:lv,external:en(te("Nachger\xFCckt","Moved up"),"green",te("Sie sind nachger\xFCckt","You have moved up"),te("Es ist ein Platz frei geworden \u2014 Ihre Bewerbung l\xE4uft weiter.","A place has become available \u2014 your application continues."))},closed:{label:te("Warteliste geschlossen","Waitlist closed"),tone:"red",phase:lv,external:en(te("Warteliste geschlossen","Waiting list closed"),"red",te("Die Warteliste wurde geschlossen","The waiting list has been closed"),te("Leider ist kein Platz mehr frei geworden.","Unfortunately no place has become available."))}},oL={outcomes:sv,inputs:s(()=>[{id:"waitlistOrder",label:{de:"Reihenfolge der Warteliste",en:"Waiting list order"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:Yt.map(e=>({value:e,label:pI[e]}))}],"inputs"),validate:s((e,n)=>{let t=ay(e);if(t===null)return[];let r=n.nodes.filter(o=>o.type==="waitlist"&&o.id!==e.id),i=n.nodes.indexOf(e);for(let o of r){if(n.nodes.indexOf(o)>i)continue;let a=ay(o);if(a!==null&&a.waitlistOrder!==t.waitlistOrder)return[{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs`,reason:{de:`[waitlist/policyConflict] Wartelisten "${o.id}" und "${e.id}" nennen verschiedene Reihenfolgen \u2014 eine Kohorte hat EINE Warteliste.`,en:`[waitlist/policyConflict] Waiting lists "${o.id}" and "${e.id}" state different orders \u2014 a cohort has ONE waiting list.`},severity:"error"}]}return[]},"validate"),pausesApplicationTasks:!0,progressDefaults:iL,progressEvents:Mn(iL),notificationEvents:s(()=>[{id:"placed",label:{de:"Auf die Warteliste gesetzt",en:"Placed on the waiting list"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"rank",type:"number"}]},{id:"promoted",label:{de:"Nachger\xFCckt",en:"Promoted from the waiting list"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"rank",type:"number"}]}],"notificationEvents"),actions:s(e=>(e.outcomes!==void 0&&e.outcomes.length>0?e.outcomes:sv).some(t=>t.id===av)?[{id:tL,kind:"advance",outcome:av,semantic:"other",label:{de:rL,en:"Promote from waitlist"},surface:kr,superUserOnly:!0,teamAssignable:!0}]:[],"actions")};var dv="complete",Rd="acceptedIncomplete",ym="rejected",W4="absage",sL="closeWithoutDocuments",aL="rejectAtCompleteness",lL="Ohne Nachreichung abschlie\xDFen",dL="Ablehnen",cL="awaitingDocuments",cv="documentsComplete",uv="closedWithoutDocuments",fv="rejected",pv="withdrawn",uL="requested",zRe={[dv]:{event:cv,status:"complete",endsRole:!0},[Rd]:{event:uv,status:"acceptedIncomplete",endsRole:!1},[ym]:{event:fv,status:"rejected",endsRole:!0},[W4]:{event:pv,status:"withdrawn",endsRole:!0}};var Id=s(()=>bl[0],"beneficiary"),mv=366;function Y4(e){let n=e.reads,t=vl(e).flatMap(({address:r})=>fn(r)&&!bl.includes(r.path)?[r]:[]);return[...Array.isArray(n)?n.filter(fn):[],...t]}s(Y4,"printedFields");function H4(e,n){let t=se(n);return e.nodes.filter(r=>r.type==="governedDocument"&&Y4(r).some(i=>se(i)===t))}s(H4,"documentsPrinting");function J4(e,n){if(!fn(n)||n.path!==Id())return!1;let t=e.nodes.find(r=>r.id===n.owner);return t!==void 0&&t.type==="form"&&!vt(t)}s(J4,"isCreatedFormBeneficiary");function qn(e,n,t){return{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${n}`,reason:t,severity:"error"}}s(qn,"issue");function Q4(e,n,t){let r=new Map(e.nodes.map(l=>[l.id,l])),i=n.next??{},o=new Set,a=[dv,Rd].flatMap(l=>{let d=i[l]?.to;return d===void 0?[]:[d]});for(;a.length>0;){let l=a.pop();if(o.has(l))continue;o.add(l);let d=r.get(l);if(d!==void 0&&!(d.type==="review"&&we(d.form)&&wr(d.form)&&d.form.owner===t)){if(d.type==="end"){if(So(d)==="approved")return!0;continue}for(let c of Object.values(d.next??{}))a.push(c.to)}}return!1}s(Q4,"reachesApprovedEndUnreviewed");var hv={key:"unterlagen",label:te("Unterlagen nachreichen","Outstanding documents"),scope:"node"},fL={[cL]:{label:te("Unterlagen nachreichen","Outstanding documents"),tone:"amber",phase:hv,external:en(te("Unterlagen fehlen","Documents missing"),"amber",te("Bitte reichen Sie die fehlenden Unterlagen nach","Please submit the missing documents"),te("Uns fehlen noch einige Angaben oder Unterlagen. Sie finden die Liste und die Frist in Ihren Aufgaben.","Some details or documents are still missing. You will find the list and the deadline in your tasks."))},[cv]:{label:te("Unterlagen vollst\xE4ndig","Documents complete"),tone:"green",phase:hv,external:en(te("Unterlagen vollst\xE4ndig","Documents complete"),"green",te("Ihre Unterlagen sind vollst\xE4ndig","Your documents are complete"),te("Alle angeforderten Unterlagen liegen uns vor. Vielen Dank.","We have received all the requested documents. Thank you."))},[uv]:{label:te("Ohne Nachreichung abgeschlossen","Closed without documents"),tone:"neutral",phase:hv,external:en(te("Abgeschlossen","Closed"),"neutral",te("Die Nachreichung ist abgeschlossen","The document request is closed"),te("Wir haben die Anforderung der Unterlagen abgeschlossen. Ihre Bewerbung l\xE4uft weiter.","We have closed the document request. Your application continues."))},[fv]:{label:te("Abgelehnt","Rejected"),tone:"red",phase:YO,external:en(te("Abgelehnt","Rejected"),"red",te("Leider k\xF6nnen wir Ihnen keinen Platz anbieten","Unfortunately we cannot offer you a place"),te("Wir bedauern, Ihnen mitteilen zu m\xFCssen, dass wir Ihre Bewerbung nicht ber\xFCcksichtigen konnten.","We regret to inform you that we were unable to accept your application."))},[pv]:{label:te("Zur\xFCckgezogen","Withdrawn"),tone:"red",phase:Ff,external:en(te("Zur\xFCckgezogen","Withdrawn"),"red",te("Sie haben Ihre Bewerbung zur\xFCckgezogen","You have withdrawn your application"),te("Ihre Bewerbung wird nicht weitergef\xFChrt.","Your application will not be continued."))}},pL={outcomes:nL,progressDefaults:fL,progressEvents:Mn(fL),notificationEvents:s(()=>[{id:uL,label:{de:"Unterlagen angefordert",en:"Documents requested"},audience:"external",required:!0,args:[{key:"applicationId",type:"string",required:!0},{key:"fieldLabels",type:"localizedText",required:!0},{key:"dueAt",type:"number",required:!0}]}],"notificationEvents"),actions:s(e=>{let n=s(r=>e.next?.[r]!==void 0,"wired"),t=[];return n(Rd)&&t.push({id:sL,kind:"advance",outcome:Rd,semantic:"other",label:{de:lL,en:"Close without documents"},surface:kr,superUserOnly:!0,confirm:{title:{de:"Unterlagen unvollst\xE4ndig",en:"Documents incomplete"},body:{de:"Es geht ohne die fehlenden Unterlagen weiter. Die Anfrage an die Familie wird geschlossen.",en:"The application continues without the missing documents. The request to the family is closed."},confirmLabel:{de:"Abschlie\xDFen",en:"Close"}}}),n(ym)&&t.push({id:aL,kind:"advance",outcome:ym,semantic:"rejected",label:{de:dL,en:"Reject application"},surface:kr,superUserOnly:!0,confirm:{title:{de:"Unterlagen unvollst\xE4ndig",en:"Documents incomplete"},body:{de:"Der Platz wird abgesagt und die Anfrage an die Familie geschlossen. Das l\xE4sst sich nicht r\xFCckg\xE4ngig machen.",en:"The application is rejected and the request to the family is closed. This cannot be undone."},confirmLabel:{de:"Ablehnen",en:"Reject"}}}),t},"actions"),inputs:s(()=>[{id:"person",label:{de:"Person (Gasth\xF6rer-Rolle)",en:"Person (guest role)"},type:"personRef",required:!1},{id:"guestRole",label:{de:"Gastrolle bis zur Nachreichung",en:"Guest role until submitted"},type:"roleKey",required:!1,inspector:"literal-only",optionSource:"tenantRoles"}],"inputs"),validate:s((e,n,t)=>{let r=[],i=`Vollst\xE4ndigkeitspr\xFCfung \u201E${e.label?.de??e.id}\u201C (${e.id})`,o=`Completeness check "${e.label?.en||e.id}" (${e.id})`,a=s(E=>Ve(n,E,"de"),"shown"),l=s(E=>Ve(n,E,"en"),"shownEn"),d=e.requires;if(!Array.isArray(d)||d.length===0)r.push(qn(e,"requires",{de:`[completenessCheck/missingRequires] ${i} nennt keine Felder \u2014 \`requires\` muss mindestens ein Feld eines Formulars enthalten ($node.<formular>.admission.<feld>).`,en:`[completenessCheck/missingRequires] ${o} names no fields \u2014 \`requires\` must contain at least one field of a form ($node.<form>.admission.<field>).`}));else{let E=new Set;for(let A of d){if(!we(A))continue;let I=se(A);if(E.has(I)){r.push(qn(e,"requires",{de:`[completenessCheck/duplicateField] Feld ${a(A)} steht doppelt in \`requires\`.`,en:`[completenessCheck/duplicateField] Field ${l(A)} appears twice in \`requires\`.`}));continue}if(E.add(I),!fn(A)){r.push(qn(e,"requires",{de:`[completenessCheck/unknownField] ${a(A)} ist kein Feld eines Formulars \u2014 \`requires\` nennt Felder ($node.<formular>.admission.<feld>).`,en:`[completenessCheck/unknownField] ${l(A)} is not a field of a form \u2014 \`requires\` names fields ($node.<form>.admission.<field>).`}));continue}let _=oi(t,A);if(_==null)continue;let T=Fs("requires",Ds(_));T==="computed"||T==="repeated"?r.push(qn(e,"requires",{de:`[completenessCheck/fieldNotRequestable] Feld ${a(A)} ist ${_.kind==="computed"?"berechnet":"ein Feld einer wiederholten Gruppe"} \u2014 die Familie kann es nicht nachreichen.`,en:`[completenessCheck/fieldNotRequestable] Field ${l(A)} is ${_.kind==="computed"?"computed":"a field of a repeated group"} \u2014 the family cannot submit it later.`})):T==="untranslated"&&r.push(qn(e,"requires",{de:`[completenessCheck/fieldNameUntranslated] Feld ${a(A)} (\u201E${Fi(_,"de")}") hat keinen englischen Namen (Feld oder Person/Abschnitt) \u2014 der Brief \u201EUnterlagen angefordert" nennt es in der Sprache der Familie.`,en:`[completenessCheck/fieldNameUntranslated] Field ${l(A)} ("${Fi(_,"de")}") has no English name (field or person/section) \u2014 the letter "Documents requested" names it in the family's language.`}))}}let c=e.deadline,u=typeof c=="object"&&c!==null?c:{},p="inDays"in u,m="until"in u;if(p===m)r.push(qn(e,"deadline",{de:`[completenessCheck/deadlineShape] Vollst\xE4ndigkeitspr\xFCfung "${e.id}" braucht genau eine Frist: \`{ inDays: n }\` (Tage ab Eintritt) oder \`{ until: "JJJJ-MM-TT" }\`.`,en:`[completenessCheck/deadlineShape] Completeness check "${e.id}" needs exactly one deadline: \`{ inDays: n }\` (days after entry) or \`{ until: "YYYY-MM-DD" }\`.`}));else if(p){let E=u.inDays;(typeof E!="number"||!Number.isInteger(E)||E<0||E>mv)&&r.push(qn(e,"deadline.inDays",{de:`[completenessCheck/deadlineDays] Frist "${String(E)}" ist keine ganze Zahl von 0 bis ${mv} Tagen.`,en:`[completenessCheck/deadlineDays] Deadline "${String(E)}" is not a whole number from 0 to ${mv} days.`}))}else typeof u.until!="string"||Qy(u.until)===null?r.push(qn(e,"deadline.until",{de:`[completenessCheck/deadlineDate] Frist "${String(u.until)}" ist kein g\xFCltiges Datum (JJJJ-MM-TT).`,en:`[completenessCheck/deadlineDate] Deadline "${String(u.until)}" is not a valid date (YYYY-MM-DD).`})):u.until<fP(Date.now())&&r.push({...qn(e,"deadline.until",{de:`[completenessCheck/deadlinePassed] Frist "${u.until}" liegt in der Vergangenheit \u2014 jede Anfrage bek\xE4me den Tag des Eintritts als Frist. Datum aktualisieren?`,en:`[completenessCheck/deadlinePassed] Deadline "${u.until}" is in the past \u2014 every request would get the day of entry as its deadline. Update the date?`}),severity:"warning"});if(Array.isArray(d)){let E=new Map(d.filter(fn).map(A=>[se(A),A]));for(let A of E.values())for(let I of H4(n,A))r.push(qn(e,"requires",{de:`[completenessCheck/requiresConsumedUpstream] Feld ${a(A)} flie\xDFt in das Dokument \u201E${I.label?.de??I.id}" (${I.id}) ein \u2014 nach dessen Ausstellung kann die Familie es nicht mehr nachreichen. Feld aus \`requires\` oder aus dem Dokument nehmen.`,en:`[completenessCheck/requiresConsumedUpstream] Field ${l(A)} flows into the document "${I.label?.en||I.id}" (${I.id}) \u2014 once it is issued, the family can no longer submit it later. Remove the field from \`requires\` or from the document.`}))}if(Array.isArray(d)&&t!==void 0){let E=d.filter(fn).filter(_=>{let T=oi(t,_);return T!=null&&rp(T)}),I=[...new Set(E.map(_=>_.owner))].filter(_=>Q4(n,e,_));if(I.length>0){let _=E.filter(T=>I.includes(T.owner));r.push({...qn(e,"next",{de:`[review/unreviewedAfterSupply] ${_.map(a).join(", ")} ist pr\xFCfpflichtig und wird hier nachgereicht, aber nach \u201Evollst\xE4ndig\u201C oder \u201Eohne Nachreichung\u201C f\xFChrt ein Weg ohne Pr\xFCfknoten dieses Formulars zur Aufnahme \u2014 niemand pr\xFCft das Nachgereichte. Dort einen Pr\xFCfknoten einf\xFCgen (z. B. \u201EWenn nichts zu pr\xFCfen ist: Durchreichen\u201C).`,en:`[review/unreviewedAfterSupply] ${_.map(l).join(", ")} requires review and is supplied here, but after "complete" or "accepted incomplete" a path without a review node of this form leads to admission \u2014 nobody reviews what was supplied. Insert a review node there (e.g. "When nothing is owed: pass through").`}),severity:"warning"})}}let y=e.inputs?.guestRole,k=y?.kind==="literal"?y.value:void 0,g=e.inputs?.person,v=g?.kind==="binding"?g.address:null;k!==void 0&&(typeof k!="string"||k.trim()===""?r.push(qn(e,"inputs.guestRole",{de:"[completenessCheck/guestRoleEmpty] `guestRole` ist leer \u2014 Rollenschl\xFCssel angeben oder das Feld weglassen.",en:"[completenessCheck/guestRoleEmpty] `guestRole` is empty \u2014 give a role key or omit the field."})):t?.roleKeys!==void 0&&!t.roleKeys.has(k)?r.push(qn(e,"inputs.guestRole",{de:`[completenessCheck/unknownRole] Rolle "${k}" existiert nicht im Rollenkatalog des Mandanten. Bekannte Rollen: ${[...t.roleKeys].sort().join(", ")}.`,en:`[completenessCheck/unknownRole] Role "${k}" does not exist in this school's role catalog. Known roles: ${[...t.roleKeys].sort().join(", ")}.`})):t?.assignableRoleKeys!==void 0&&!t.assignableRoleKeys.has(k)&&r.push(qn(e,"inputs.guestRole",{de:`[completenessCheck/nonLeafRole] Rolle "${k}" hat untergeordnete Rollen und ist nicht vergebbar.`,en:`[completenessCheck/nonLeafRole] Role "${k}" has sub-roles and cannot be assigned.`})),v===null&&r.push(qn(e,"inputs.person",{de:`[completenessCheck/guestRoleNeedsPerson] ${i} vergibt die Rolle "${String(k)}", aber der Eingang \u201Eperson" ist nicht gebunden (z. B. an $node.<formular>.${it}.${Id()}).`,en:`[completenessCheck/guestRoleNeedsPerson] ${o} assigns the role "${String(k)}", but the input "person" is not bound (e.g. to $node.<form>.${it}.${Id()}).`}))),we(v)&&!J4(n,v)&&r.push(qn(e,"inputs.person",{de:`[completenessCheck/personNotFormParty] Eingang \u201Eperson" ist an ${a(v)} gebunden \u2014 die Pr\xFCfung vergibt die Rolle der Person, f\xFCr die ein Formular abgeschickt wurde ($node.<anlegender Formularknoten>.${it}.${Id()}).`,en:`[completenessCheck/personNotFormParty] The input "person" is bound to ${l(v)} \u2014 the check assigns the role to the person a form was submitted for ($node.<creating form node>.${it}.${Id()}).`})),v!==null&&k===void 0&&r.push(qn(e,"inputs.person",{de:'[completenessCheck/personWithoutRole] Eingang \u201Eperson" ist gebunden, aber es wird keine Rolle vergeben \u2014 die Bindung wirkt nicht.',en:'[completenessCheck/personWithoutRole] The input "person" is bound, but no role is assigned \u2014 the binding has no effect.'}));for(let E of["complete","rejected"])e.next?.[E]===void 0&&r.push(qn(e,`next.${E}`,{de:`[completenessCheck/unroutedOutcome] Vollst\xE4ndigkeitspr\xFCfung "${e.id}" leitet den Ausgang "${E}" nirgendwohin.`,en:`[completenessCheck/unroutedOutcome] Completeness check "${e.id}" routes the outcome "${E}" nowhere.`}));return r},"validate")};var Z4=[{id:hI,label:{de:"Gepr\xFCft",en:"Reviewed"},semantic:"other"}],wm=s(e=>e,"asDecision"),mL={[gI]:{label:te("Eingereicht","Submitted"),tone:"blue",phase:{key:"pruefung",label:te("In Pr\xFCfung","In review"),scope:"node"},external:en(te("Eingereicht","Submitted"),"blue",te("Ihre Bewerbung wird gepr\xFCft","Your application is being reviewed"),te("Ihre Bewerbung ist bei uns eingegangen. Wir pr\xFCfen jetzt Ihre Unterlagen und melden uns, falls etwas fehlt.","We have received your application. We are now reviewing your documents and will get in touch if anything is missing."))}},hL={role:"user-action",effect:"side-effect",outcomes:Z4,progressDefaults:mL,progressEvents:Mn(mL),notificationEvents:s(e=>Bo.notificationEvents(wm(e)),"notificationEvents"),inputs:s(()=>[{id:Xt,label:{de:"Wenn nichts zu pr\xFCfen ist",en:"When nothing is owed"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:No.map(e=>({value:e,label:N_[e]}))}],"inputs"),actions:s(e=>[...Bo.actions(wm(e)).map(n=>n.kind==="advance"&&(e.outcomes??[]).length===1?{...n,label:{de:"Pr\xFCfung abschlie\xDFen",en:"Complete review"}}:n),{id:cy,kind:"internal",label:{de:"Feld abhaken",en:"Tick field"}}],"actions"),optionalActionKinds:Bo.optionalActionKinds,workItemTemplates:s(e=>Bo.workItemTemplates(wm(e)).map(n=>n.key===ga?{...n,title:e.decisionAsTask?.title??{de:"Angaben pr\xFCfen",en:"Review the application"},unlocks:[...n.unlocks,cy]}:n),"workItemTemplates"),taskDocuments:s(()=>[],"taskDocuments"),validate:s((e,n,t)=>{let r=ov(wm(e),n,t);for(let c of e.outcomes??[]){let u=c.semantic;typeof u!="string"||!mf.includes(u)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes`,reason:{de:`[review/rejectingOutcome] Pr\xFCf-Knoten "${e.id}" deklariert das Outcome "${c.id}" mit der Bedeutung "${String(u)}" \u2014 eine Pr\xFCfung lehnt nicht ab und setzt nicht auf die Warteliste; das ist die Entscheidung der Freigabe bzw. \u201EBewerbung ablehnen".`,en:`[review/rejectingOutcome] Review node "${e.id}" declares the outcome "${c.id}" meaning "${String(u)}" \u2014 a review neither rejects nor waitlists; that is the decision of the approval or "Reject application".`},severity:"error"})}let i={de:`\u201E${e.label?.de??e.id}\u201C (${e.id})`,en:`"${e.label?.en||e.id}" (${e.id})`},o=e.inputs?.[Xt],a=__(e);o!==void 0&&a===null&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.${Xt}`,reason:{de:`[review/unknownMode] Pr\xFCf-Knoten ${i.de}: \u201EWenn nichts zu pr\xFCfen ist\u201C muss ${No.join(" oder ")} als fester Wert sein.`,en:`[review/unknownMode] Review node ${i.en}: "When nothing is owed" must be the literal ${No.join(" or ")}.`},severity:"error"});let l=a==="advance",d=e.form;if(l&&d===void 0&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.form`,reason:{de:`[review/advanceNeedsForm] Pr\xFCf-Knoten ${i.de} reicht durch, wenn nichts zu pr\xFCfen ist, nennt aber kein Formular \u2014 er w\xFCrde immer durchreichen. Nenne das Formular, dessen pr\xFCfpflichtige Felder er pr\xFCft.`,en:`[review/advanceNeedsForm] Review node ${i.en} passes through when nothing is owed but names no form \u2014 it would always pass through. Name the form whose review-required fields it checks.`},severity:"error"}),l&&(e.outcomes??[]).length!==1&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes`,reason:{de:`[review/advanceOneOutcome] Pr\xFCf-Knoten ${i.de} reicht durch, hat aber ${(e.outcomes??[]).length} Outcomes \u2014 durchgereicht wird \xFCber genau eines.`,en:`[review/advanceOneOutcome] Review node ${i.en} passes through but has ${(e.outcomes??[]).length} outcomes \u2014 it passes through over exactly one.`},severity:"error"}),we(d)&&wr(d)){let c=t?.readinessFormFieldsByFormNode?.get(d.owner);c!==void 0&&![...c.values()].some(rp)&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.form`,reason:l?{de:`[review/nothingDeclared] Pr\xFCf-Knoten ${i.de} pr\xFCft ${se(d)}, aber dieses Formular erkl\xE4rt kein Feld als pr\xFCfpflichtig \u2014 der Schritt w\xFCrde jedes Mal durchreichen. Markiere die Felder im Formular als \u201EPr\xFCfpflichtig\u201C.`,en:`[review/nothingDeclared] Review node ${i.en} reviews ${se(d)}, but that form declares no field review-required \u2014 the step would pass through every time. Mark the fields "Review required" in the form.`}:{de:`[review/nothingDeclared] Pr\xFCf-Knoten ${i.de} pr\xFCft ${se(d)}, aber dieses Formular erkl\xE4rt kein Feld als pr\xFCfpflichtig \u2014 der Schritt wartet, ohne dass etwas abzuhaken ist. Markiere die Felder im Formular als \u201EPr\xFCfpflichtig\u201C.`,en:`[review/nothingDeclared] Review node ${i.en} reviews ${se(d)}, but that form declares no field review-required \u2014 the step waits with nothing to tick. Mark the fields "Review required" in the form.`},severity:l?"error":"warning"})}return r},"validate")};var gL=["awaitingAnswer","answered"];async function yL(e,n){return(await Pl(e,{applicationId:n.applicationId,nodeId:n.nodeId})).filter(r=>r.templateKey===n.templateKey).some(r=>r.isOpen)?"awaitingAnswer":"answered"}s(yL,"externalRequestState");var bL=[{id:Ns,label:{de:"Bezahlt",en:"Paid"}}],OIe=new Set(bL.map(e=>e.id));var X4=Ns,wL=[{id:X4,kind:"advance",outcome:Ns,semantic:"other",label:{de:"Zahlung eingegangen",en:"Payment received"},availableIn:["awaitingAnswer"]}],e3={id:My,kind:"advance",outcome:Ns,semantic:"other",label:{de:"Zahlung \xFCberspringen",en:"Skip payment"},surface:kr,superUserOnly:!0,confirm:{title:{de:"Zahlung \xFCberspringen",en:"Skip payment"},body:{de:"Die Geb\xFChr wird au\xDFerhalb von Plexus abgerechnet. Der Schritt wird ohne Zahlung abgeschlossen; es wird kein Betrag als bezahlt verbucht.",en:"The fee is billed outside Plexus. The step is completed without a payment; no amount is recorded as paid."},confirmLabel:{de:"\xDCberspringen",en:"Skip"}}},n3={id:My,kind:"advance",outcome:Ns,semantic:"other",label:{de:"Ohne Online-Zahlung abschlie\xDFen",en:"Close without online payment"},surface:kr,superUserOnly:!0,availableIn:["awaitingAnswer"],confirm:{title:{de:"Ohne Online-Zahlung abschlie\xDFen",en:"Close without online payment"},body:{de:"Die Familie hat nicht online \xFCber Plexus bezahlt. Der Schritt wird ohne Online-Zahlung abgeschlossen; eine offene Zahlungsseite wird geschlossen. Bitte den Grund angeben (z. B. bar bezahlt).",en:"The family did not pay online through Plexus. The step is completed without an online payment; an open payment page is closed. Please give the reason (e.g. paid in cash)."},confirmLabel:{de:"Abschlie\xDFen",en:"Complete"}},commentRequired:!0};function gv(e,n){let t=e.inputs?.[n];return t?.kind==="literal"?t.value:void 0}s(gv,"literalOf");function ya(e){let n=gv(e,Ht);return Tf(n)?n:null}s(ya,"settlementOrNull");function t3(e){let n=gv(e,Ci);return typeof n=="string"&&n.length>0?n:null}s(t3,"articleKeyOrNull");function r3(e){let n=gv(e,Jt);return typeof n=="string"&&n.length>0&&n===n.trim()?n:null}s(r3,"payeeKeyOrNull");var i3={id:Ci,label:{de:"Artikel",en:"Article"},type:"article",required:!0,inspector:"literal-only",optionSource:"programArticles"},o3={id:Ht,label:{de:"Abrechnung",en:"Settlement"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:[{value:"separate",label:{de:"Separat (Schule)",en:"Separately (school)"}},{value:"online",label:{de:"Online (Stripe)",en:"Online (Stripe)"}}]},s3={id:Di,label:{de:"Hinweis f\xFCr die Familie",en:"Note for the family"},type:"localizedText",required:!1,inspector:"literal-only"},a3={id:Jt,label:{de:"Zahlungsempf\xE4nger (Tr\xE4ger)",en:"Payee (legal entity)"},type:"legalEntity",required:!0,inspector:"literal-only",optionSource:"tenantTraeger"};function l3(e){return[i3,o3,...ya(e)==="online"?[a3]:[],s3]}s(l3,"collectPaymentInputs");var d3=["amount","currency","settlement"];function c3(e,n){if(ya(e)!=="online")return[];let t=r3(e);if(t===null)return[];let r=`nodes.${e.id}.inputs.${Jt}`,i=s(o=>({layer:"GRAPH",kind:"nodeRule",path:r,reason:o,severity:"error"}),"at");return n?.traeger!==void 0&&!n.traeger.has(t)?[i({de:`[collectPayment/unknownPayee] Zahlungsempf\xE4nger \u201E${t}" ist kein Tr\xE4ger dieses Mandanten \u2014 bekannt: ${[...n.traeger.keys()].join(", ")||"(keiner)"}.`,en:`[collectPayment/unknownPayee] Payee "${t}" is not a legal entity of this school \u2014 known: ${[...n.traeger.keys()].join(", ")||"(none)"}.`})]:n?.stripeReadyTraegerKeys!==void 0&&!n.stripeReadyTraegerKeys.has(t)?[i({de:`[collectPayment/onlineWithoutStripe] Abrechnung \u201Eonline" an \u201E${t}" setzt voraus, dass dieser Tr\xE4ger ein einsatzbereites Stripe-Konto hat (Administration \u2192 Integrationen \u2192 Stripe, Tr\xE4ger \u201E${t}") \u2014 sonst kann keine Familie bezahlen. Bis dahin \u201Eseparat" w\xE4hlen.`,en:`[collectPayment/onlineWithoutStripe] Settlement "online" to "${t}" requires this legal entity to have a ready Stripe account (Administration \u2192 Integrations \u2192 Stripe, legal entity "${t}") \u2014 otherwise no family can pay. Until then, choose "separate".`})]:[]}s(c3,"payeeIssues");var kL={awaitingPayment:{label:te("Zahlung ausstehend","Awaiting payment"),tone:"amber",phase:{key:"zahlung",label:te("Zahlung","Payment"),scope:"node"},external:en(te("Zahlung offen","Payment due"),"amber",te("Bitte begleichen Sie die Anmeldegeb\xFChr","Please pay the application fee"),te("Ihre Bewerbung l\xE4uft weiter, sobald die Zahlung bei uns eingegangen ist.","Your application continues as soon as we have received the payment."))}},vL={outputs:s(()=>[{name:eO,type:"object",label:{de:"Zahlung",en:"Payment"}}],"outputs"),role:"user-action",effect:"side-effect",inputs:s(e=>l3(e),"inputs"),outcomes:bL,progressDefaults:kL,progressEvents:Mn(kL),notificationEvents:s(e=>ya(e)!=="online"?[]:[{id:"requested",label:{de:"Zahlung angefordert",en:"Payment requested"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"amount",type:"number",required:!0}]}],"notificationEvents"),actions:s(e=>{let n=ya(e);return n==="online"?[...wL,n3]:n==="separate"?[e3]:[]},"actions"),states:gL,currentState:s((e,n)=>yL(e,{applicationId:n.applicationId,nodeId:n.node.id,templateKey:rv}),"currentState"),workItemTemplates:s(e=>{let n=e;return ya(n)!=="online"?[]:[{key:rv,recipient:"external",title:n.label,unlocks:wL.map(t=>t.id),advancesNode:!0}]},"workItemTemplates"),validate:s((e,n,t)=>{let r=[],i=s((d,c)=>r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${d}`,reason:c,severity:"error"}),"push");for(let d of d3)d in e&&i(d,{de:`[collectPayment/retiredField] \u201E${d}" steht nicht mehr am Zahlungsknoten \u2014 Betrag und W\xE4hrung kommen aus dem Artikel (Parameter \u201EArtikel"), die Abrechnung ist der Parameter \u201EAbrechnung" (inputs.settlement).`,en:`[collectPayment/retiredField] "${d}" is no longer on the payment node \u2014 amount and currency come from the article (parameter "Article"), and settlement is the parameter "Settlement" (inputs.settlement).`});r.push(...c3(e,t)),ya(e)===null&&i(`inputs.${Ht}`,{de:`[collectPayment/invalidSettlement] Abrechnung muss eine von ${Ps.join(", ")} sein (online = die Familie zahlt im Portal, separate = die Schule rechnet au\xDFerhalb von Plexus ab); erhalten ${JSON.stringify(e.inputs?.[Ht])}.`,en:`[collectPayment/invalidSettlement] Settlement must be one of ${Ps.join(", ")} (online = the family pays in the portal, separate = the school bills outside Plexus); received ${JSON.stringify(e.inputs?.[Ht])}.`});let o=e.inputs?.[Di];if(o?.kind==="literal"){let d=Ef(o.value);d!==null&&i(`inputs.${Di}`,{de:`[collectPayment/reasonText] Der Hinweis f\xFCr die Familie braucht einen Text auf Deutsch und auf Englisch (${d}).`,en:`[collectPayment/reasonText] The note for the family needs a text in German and in English (${d}).`})}let a=t3(e);if(a===null)return i(`inputs.${Ci}`,{de:'[collectPayment/missingArticle] Der Zahlungsknoten nennt keinen Artikel \u2014 unter \u201EParameter" einen einmaligen Artikel des Programms w\xE4hlen (Finanzen \u2192 Artikel).',en:'[collectPayment/missingArticle] The payment node names no article \u2014 under "Parameters" choose a one-time article of the program (Finance \u2192 Articles).'}),r;let l=`inputs.${Ci}`;return t?.billingItemKeys!==void 0&&!t.billingItemKeys.has(a)?(i(l,{de:`[collectPayment/unknownArticle] Artikel \u201E${a}" \u2014 kein Artikel dieses Mandanten tr\xE4gt diesen Schl\xFCssel.`,en:`[collectPayment/unknownArticle] Article "${a}" \u2014 no article of this school has this key.`}),r):(t?.oneTimeBillingItemKeys!==void 0&&!t.oneTimeBillingItemKeys.has(a)&&i(l,{de:`[collectPayment/articleNotOneTime] Artikel \u201E${a}" ist kein einmaliger Artikel \u2014 eine Geb\xFChr nimmt nur ${qy.join(", ")}.`,en:`[collectPayment/articleNotOneTime] Article "${a}" is not a one-time article \u2014 a fee only takes ${qy.join(", ")}.`}),t?.offerProgram===null?i(l,{de:"[collectPayment/articleOfferWithoutProgram] Das Angebot ist keinem Programm zugeordnet, also geh\xF6rt kein Artikel zu ihm; dem Angebot ein Programm geben.",en:"[collectPayment/articleOfferWithoutProgram] The offer is not assigned to a program, so no article belongs to it; give the offer a program."}):t?.offerProgram?.directBillingItemKeys!==void 0&&!t.offerProgram.directBillingItemKeys.has(a)&&i(l,{de:`[collectPayment/articleNotInProgram] Artikel \u201E${a}" ist dem Programm \u201E${t.offerProgram.nameDe}" des Angebots nicht direkt zugeordnet \u2014 unter Finanzen \u2192 Artikel zuordnen (ein Paket z\xE4hlt nicht: es kann den Artikel anders bepreisen).`,en:`[collectPayment/articleNotInProgram] Article "${a}" is not directly assigned to the offer's program "${t.offerProgram.nameDe}" \u2014 assign it under Finance \u2192 Articles (a package does not count: it can price the article differently).`}),r)},"validate")};function xL(e){return{de:`[governedDocument/localeFieldMissing] Die Vorlage "${e}" nennt kein Sprachfeld \u2014 ein Schreiben entsteht in genau einer Sprache. Ein Pflicht-Auswahlfeld mit den Optionen de/en unter den Parametern der Vorlage anlegen, es als localeField der Vorlage nennen und im Knoten an die Sprache des Benutzerkontos binden ($env.applicant.language); die Word-Datei h\xE4lt je Sprache einen Abschnitt <<#input.<feld>.de>> \u2026 <</input.<feld>.de>>.`,en:`[governedDocument/localeFieldMissing] The template "${e}" names no language field \u2014 a letter is written in exactly one language. Create a required choice field with the options de/en among the template's parameters, name it as the template's localeField and bind it in the node to the language of the user account ($env.applicant.language); the Word file holds one section per language <<#input.<field>.de>> \u2026 <</input.<field>.de>>.`}}s(xL,"localeFieldMissingText");var yv=new Set(["string","email","tel","number","date","boolean","enum","pricedItem"]),SL=/^[a-z][a-z0-9_]*$/;function AL(e,n){let t=[],r=e?.fields;if(!Array.isArray(r))return[{path:"",reason:{de:`[governedDocument/missingTemplateFields] Die Vorlage "${n}" deklariert keine Parameter \u2014 erwartet wird { fields } (die Platzhalter input.<schl\xFCssel>, die ein Knoten f\xFCllt).`,en:`[governedDocument/missingTemplateFields] The template "${n}" declares no parameters \u2014 expected { fields } (the placeholders input.<key> a node fills).`}}];let i=r,o=new Set;for(let a of i){if(typeof a?.key!="string"||!SL.test(a.key)||o.has(a.key)){t.push({path:`fields.${String(a?.key)}`,reason:{de:`[governedDocument/templateFieldKey] Feld "${String(a?.key)}" der Vorlage "${n}" ist ${o.has(a?.key)?"doppelt":"kein g\xFCltiger Schl\xFCssel"} \u2014 erlaubt sind eindeutige Kleinbuchstaben, Ziffern und _ (gedruckt als input.<schl\xFCssel>).`,en:`[governedDocument/templateFieldKey] Field "${String(a?.key)}" of the template "${n}" is ${o.has(a?.key)?"duplicated":"not a valid key"} \u2014 allowed are unique lower-case letters, digits and _ (printed as input.<key>).`}});continue}o.add(a.key);let l=`fields.${a.key}`;if(!_i(a.type)){t.push({path:l,reason:{de:`[governedDocument/unknownFieldType] Vorlage "${n}" typisiert das Feld "${a.key}" als "${String(a.type)}" \u2014 das geh\xF6rt nicht zum Wert-Vokabular der Plattform (${Os.join(", ")}).`,en:`[governedDocument/unknownFieldType] Template "${n}" types the field "${a.key}" as "${String(a.type)}" \u2014 that is not part of the platform's value vocabulary (${Os.join(", ")}).`}});continue}if(yv.has(a.type)||t.push({path:l,reason:{de:`[governedDocument/templateFieldType] Feld "${a.key}" der Vorlage "${n}" hat den Typ "${a.type}" \u2014 ein Brief druckt nur ${[...yv].join(", ")}.`,en:`[governedDocument/templateFieldType] Field "${a.key}" of the template "${n}" has the type "${a.type}" \u2014 a letter only prints ${[...yv].join(", ")}.`}}),a.type==="enum"&&Array.isArray(a.options)&&a.options.some(d=>!SL.test(String(d.value)))&&t.push({path:l,reason:{de:`[governedDocument/templateFieldKey] Auswahlfeld "${a.key}" der Vorlage "${n}" hat Optionen, die kein Platzhalter adressieren kann (${a.options.map(d=>d.value).join(", ")}) \u2014 Optionswerte sind Kleinbuchstaben, Ziffern und _ (gedruckt als input.${a.key}.<option>).`,en:`[governedDocument/templateFieldKey] Select field "${a.key}" of the template "${n}" has options no placeholder can address (${a.options.map(d=>d.value).join(", ")}) \u2014 option values are lower-case letters, digits and _ (printed as input.${a.key}.<option>).`}}),a.type==="enum"&&(!Array.isArray(a.options)||a.options.length===0)&&t.push({path:l,reason:{de:`[governedDocument/templateFieldOptions] Auswahlfeld "${a.key}" der Vorlage "${n}" nennt keine Optionen \u2014 ohne sie gibt es keine Abschnitte input.${a.key}.<option>.`,en:`[governedDocument/templateFieldOptions] Select field "${a.key}" of the template "${n}" names no options \u2014 without them there are no sections input.${a.key}.<option>.`}}),a.type==="pricedItem"){let d=i.find(c=>c.key===a.priceDate);(d===void 0||d.type!=="date")&&t.push({path:l,reason:{de:`[governedDocument/templateFieldPriceDate] Preisfeld "${a.key}" der Vorlage "${n}" nennt kein Preisdatum \u2014 priceDate muss ein Datumsfeld derselben Vorlage sein (welche Preisversion gilt); genannt: ${JSON.stringify(a.priceDate)}.`,en:`[governedDocument/templateFieldPriceDate] Price field "${a.key}" of the template "${n}" names no price date \u2014 priceDate must be a date field of the same template (which price version applies); named: ${JSON.stringify(a.priceDate)}.`}})}else a.priceDate!==void 0&&t.push({path:l,reason:{de:`[governedDocument/templateFieldPriceDate] Feld "${a.key}" setzt priceDate, ist aber kein Preisfeld (pricedItem).`,en:`[governedDocument/templateFieldPriceDate] Field "${a.key}" sets priceDate but is not a price field (pricedItem).`}});a.processSource==="countersignature"?t.push({path:l,reason:{de:`[governedDocument/countersignatureInTemplate] Feld "${a.key}" wird bei einer Gegenzeichnung gesetzt \u2014 ein Brief aus einer Vorlage wird nicht gegengezeichnet.`,en:`[governedDocument/countersignatureInTemplate] Field "${a.key}" is set at a countersignature \u2014 a letter from a template is not countersigned.`}}):a.processSource!==void 0&&!fp.includes(a.processSource)&&t.push({path:l,reason:{de:`[governedDocument/unknownProcessSource] Feld "${a.key}" nennt die unbekannte Vorgangsquelle "${String(a.processSource)}" \u2014 bekannt sind ${fp.join(", ")}.`,en:`[governedDocument/unknownProcessSource] Field "${a.key}" names the unknown case source "${String(a.processSource)}" \u2014 known are ${fp.join(", ")}.`}})}return t.push(...u3(e,n)),t}s(AL,"templateParameterIssues");function u3(e,n){if(e.localeField===void 0)return[{path:"localeField",reason:xL(n)}];let t=e.fields.find(i=>i.key===e.localeField),r=t===void 0?{de:"nennt kein Feld der Vorlage",en:"names no field of the template"}:t.type!=="enum"?{de:`ist ${t.type}, erwartet wird ein Auswahlfeld (enum)`,en:`is ${t.type}, a select field (enum) is expected`}:t.required!==!0?{de:"ist kein Pflichtfeld \u2014 ohne Sprache gibt es keine Variante",en:"is not a required field \u2014 without a language there is no variant"}:(t.options??[]).length===0?{de:"hat keine Optionen",en:"has no options"}:(t.options??[]).some(i=>!We.includes(i.value))?{de:`hat Optionen, die keine Sprache sind (erlaubt: ${We.join(", ")})`,en:`has options that are not a language (allowed: ${We.join(", ")})`}:null;return r===null?[]:[{path:"localeField",reason:{de:`[governedDocument/localeField] Das Sprachfeld "${e.localeField}" der Vorlage "${n}" ${r.de}.`,en:`[governedDocument/localeField] The language field "${e.localeField}" of the template "${n}" ${r.en}.`}}]}s(u3,"localeFieldIssues");function EL(e,n){if(n===null){delete e.templateStamp;return}e.templateStamp={fields:structuredClone(n.fields),...n.localeField===void 0?{}:{localeField:n.localeField}}}s(EL,"applyTemplateStamp");var wv=50;async function km(e,n){let t=await e.db.query("signing_returns").withIndex("by_signingRequestId",r=>r.eq("signingRequestId",n)).take(wv+1);return t.length>wv&&F(`signing_returns: Vorgang ${n} has more than ${wv} returns`),t}s(km,"returnsOf");var kv=50;async function bv(e,n){let t=await e.db.query("signing_return_documents").withIndex("by_signingReturnId_and_order",r=>r.eq("signingReturnId",n)).take(kv+1);return t.length>kv&&F(`signing_returns: return ${n} has more than ${kv} files`),t.length===0&&F(`[signing/noDocument] return ${n} carries no file`),t}s(bv,"returnDocumentsOf");async function TL(e,n){let t=await bv(e,n);return t.length!==1&&F(`[signing/severalDocuments] return ${n} carries ${t.length} files; this reader handles one`),t[0]}s(TL,"soleReturnDocumentOf");var bm=200,YIe=bm*20;async function f3(e,n){let t=await e.db.get(n);return t===null&&F(`[process] application ${n} not found`),t.redactedAt!==void 0}s(f3,"processRedacted");async function vv(e,n){await f3(e,n)&&le("CONFLICT",{de:"Die Daten dieser Bewerbung wurden gel\xF6scht.",en:"The data of this application has been deleted."})}s(vv,"assertProcessReadable");function p3(e){let n={_id:e._id,_creationTime:e._creationTime,owner:e.owner,key:e.key};return e.scope==="task"?{...n,scope:"task",result:{kind:"value",value:e.value},writtenByTaskId:e.writtenByTaskId}:{...n,scope:"node",result:e.result}}s(p3,"rowOf");async function $L(e,n,t){await vv(e,n);let r=await e.db.query("process_store_entries").withIndex("by_applicationId_and_scope_and_owner_and_key",i=>i.eq("applicationId",n).eq("scope",t.scope).eq("owner",t.owner).eq("key",t.key)).order("desc").take(bm+1);return r.length>bm&&F(`[process] application ${n} has more than ${bm} results of ${t.scope}.${t.owner}.${t.key}`),r.map(p3)}s($L,"storeHistory");async function m3(e,n,t){if(t.key===it){await vv(e,n);let i=await e.db.query("smart_form_instances").withIndex("by_applicationId_and_formNodeId",o=>o.eq("applicationId",n).eq("formNodeId",t.owner)).unique();return i===null||i.state!=="committed"?{state:"pending",reason:null}:{state:"present",result:{kind:"ref",ref:{kind:"form",formInstanceId:i._id}},row:null}}let[r]=await $L(e,n,{scope:"node",owner:t.owner,key:t.key});return r===void 0?{state:"pending",reason:null}:{state:"present",result:r.result,row:r}}s(m3,"nodeResultAt");async function vm(e,n){let t={scope:"node",owner:n.nodeId,key:n.key};return h3(await m3(e,n.applicationId,t),t,n.applicationId)}s(vm,"readOwnResult");function h3(e,n,t){return e.state!=="present"?{state:"pending"}:(e.result.kind!=="ref"&&F(`[process] ${se(n)} of application ${t} holds a value \u2014 this address holds a ref`),{state:"ref",ref:e.result.ref,row:e.row})}s(h3,"refOf");var xv={pending:"open",sent:"open",partially_signed:"open",completed:"terminal",declined:"terminal",voided:"terminal",expired:"terminal",failed:"terminal"},g3=Object.keys(xv),y3=g3.filter(e=>xv[e]==="open"),rOe=y3.filter(e=>e!=="pending");function RL(e){return xv[e]==="terminal"}s(RL,"isTerminalSigningStatus");var Ui=["docusign","insign"];var Od={docusign:"DocuSign",insign:"inSign",manual:"Auf Papier",simulated:"Simuliert (Testmodus)"};var k3=RL;function OL(e){return!k3(e.status)&&e.voidRequestedAt===void 0}s(OL,"holdsContract");async function PL(e,n){return await e.db.query("legal_entities").withIndex("by_partyId",t=>t.eq("partyId",n)).unique()}s(PL,"traegerLegalEntityOfParty");async function b3(e,n){return await e.db.query("organizations").withIndex("by_partyId",r=>r.eq("partyId",n)).first()!==null}s(b3,"isOrganizationParty");async function NL(e,n){return await PL(e,n)!==null?"traeger":await b3(e,n)?"organization":"person"}s(NL,"signerKindOf");async function _L(e,n){n.length===0&&F("signingSideOf: a Vorgang without signers asks nobody");for(let t of n)if(await v3(e,t.partyId)==="family")return"family";return"traeger"}s(_L,"signingSideOf");async function v3(e,n){return await NL(e,n)==="traeger"?"traeger":"family"}s(v3,"sideOfParty");var FOe=16*1024;var LOe=15*6e4;var MOe=10*6e4;var Sv={contractSnapshotId:Yn.restrict(w.id("contract_snapshots")),storageId:Yn.restrict(w.id("_storage")),sha256:w.string(),filename:w.string(),uploadedAt:w.number(),signers:w.array(w.object({partyId:Yn.history(w.id("parties")),role:w.string()}))},nPe=Jr({tenantId:Yn.tenant(w.id("tenants")),signingRequestDocumentId:Yn.belongsTo(w.id("signing_request_documents")),...Sv}).index("by_tenantId",["tenantId"]).index("by_signingRequestDocumentId",["signingRequestDocumentId"]).index("by_contractSnapshotId",["contractSnapshotId"]).index("by_storageId",["storageId"]);var sPe=w.object(Sv);var Av=200;async function S3(e,n,t,r){n.length>Av&&F(`${r} is carried by more than ${Av} signing requests`);let i=[],o=new Set;for(let l of n){if(o.has(l.signingRequestId))continue;o.add(l.signingRequestId);let d=await e.db.get(l.signingRequestId);d===null&&F(`signing_request_documents ${l._id} names a missing signing request ${l.signingRequestId}`),i.push(d)}let a=t==="asc"?1:-1;return i.sort((l,d)=>a*(l._creationTime-d._creationTime))}s(S3,"requestsOfMembers");async function CL(e,n,t="asc"){let r=await e.db.query("signing_request_documents").withIndex("by_contractSnapshotId",i=>i.eq("contractSnapshotId",n)).take(Av+1);return await S3(e,r,t,`revision ${n}`)}s(CL,"requestsOfSnapshot");var DL=100;async function A3(e,n){let t=await CL(e,n);t.length>DL&&F(`requestsBySideOf: revision ${n} has more than ${DL} Vorg\xE4nge`);let r={family:[],traeger:[]};for(let i of t.sort((o,a)=>o._creationTime-a._creationTime))r[await _L(e,i.signers)].push(i);return r}s(A3,"requestsBySideOf");async function Ev(e,n){return(await A3(e,n)).family}s(Ev,"familyRequestsOf");var Tv=100;async function E3(e,n){let t=await e;return t.length>Tv&&F(`contractChain: more than ${Tv} ${n}`),t}s(E3,"bounded");async function T3(e,n,t){let r=await vm(e,{applicationId:n,nodeId:t,key:Ts});return r.state==="pending"?null:(r.ref.kind!=="contract"&&F(`contractChain: $node.${t}.${Ts} of application ${n} is a ${r.ref.kind} ref \u2014 the contract chain writes a contract ref`),r.ref.contractId)}s(T3,"nodeContractRef");async function FL(e,n){return await E3(e.db.query("contract_snapshots").withIndex("by_contractId_and_revisionNumber",t=>t.eq("contractId",n)).take(Tv+1),`revisions on contract ${n}`)}s(FL,"snapshotsAsc");async function $v(e,n){let t=(await Ev(e,n)).filter(OL);return t.length>1&&F(`contractChain: revision ${n} has ${t.length} open family Vorg\xE4nge`),t[0]??null}s($v,"openFamilyRequest");async function $3(e,n){for(let t of await FL(e,n))if((await Ev(e,t._id)).some(r=>r.provider==="manual"))return"paper";return"provider"}s($3,"familyRoute");async function LL(e,n){for(let t of n)if(await $3(e,t)==="paper")return"paper";return"provider"}s(LL,"familyRouteOf");async function R3(e,n){let t=await TL(e,n._id),r=await e.db.system.get("_storage",t.storageId);return r===null&&F(`contractChain: return ${n._id} holds missing file ${t.storageId}`),{_id:n._id,_creationTime:n._creationTime,storageId:t.storageId,filename:t.filename,...r.contentType!==void 0?{mimeType:r.contentType}:{},round:n._id}}s(R3,"toReturn");function xm(e){async function n(a,l){return await T3(a,l,e.id)}s(n,"contractOrNull");async function t(a,l,d,c){let u=a.db.normalizeId("contract_snapshots",d),p=u===null?null:await a.db.get(u),m=await n(a,l);return(p===null||m===null||p.contractId!==m)&&F(`${c}: ${d} is no revision of node "${e.id}"'s contract ${m??"(none yet)"} \u2014 corrupt arc`),p}s(t,"snapshotOf");async function r(a,l){let d=await n(a,l);return d===null?null:(await FL(a,d)).at(-1)??null}return s(r,"newestSnapshot"),{reads:{kind:"contract",async returned(a,l,d){if(d.askedAbout===void 0){if(d.onUnpinned==="notReturned")return null;F(`returned(${d.where}): an ask of the contract chain is always pinned to its revision`)}let c=await t(a,l,d.askedAbout,`returned(${d.where})`),u=await $v(a,c._id);if(u===null)return null;let p=(await km(a,u._id)).filter(m=>m.review.status==="pending"&&m._id!==d.rejected);return p.length>1&&F(`returned(${d.where}): Vorgang ${u._id} has ${p.length} returns pending \u2014 one is checked at a time`),p[0]===void 0?null:await R3(a,p[0])},pinOf(a){return a.contractSnapshotId},returnPinOf(a){return a.signingReturnId}},contractOrNull:n,snapshotOf:t,newestSnapshot:r,contractsOf:{async contractsOf(a,l){let d=await n(a,l);return d===null?[]:[d]}}.contractsOf}}s(xm,"contractNodeReads");function Sm(e){return e.addedParts??[]}s(Sm,"addedPartsOf");var Rv=50;async function I3(e,n){let t=await e.db.query("contract_generation_runs").withIndex("by_packageRunId",r=>r.eq("packageRunId",n)).take(Rv+1);return t.length>Rv&&F(`groupRunsOf: generation group ${n} has more than ${Rv} runs`),t.length===0&&F(`groupRunsOf: generation group ${n} has no run`),t.sort((r,i)=>r._creationTime-i._creationTime)}s(I3,"groupRunsOf");async function ML(e,n){let t=await I3(e,n),r=t[0].packageRunId;if(r!==void 0){(t.some(l=>l.packageRunId!==r||l.partKey===void 0)||new Set(t.map(l=>l.partKey)).size!==t.length)&&F(`groupRunsInOrder: package group ${n} has inconsistent members`);let i=await e.db.get(r);i===null&&F(`groupRunsInOrder: package run ${n} is missing`);let o=await e.db.query("contract_package_parts").withIndex("by_packageRevisionId_and_position",l=>l.eq("packageRevisionId",i.packageRevisionId)).take(51),a=[...o.map(l=>l.partKey),...Sm(i).map(l=>l.partKey)];return(o.length>50||t.some(l=>!a.includes(l.partKey)))&&F(`groupRunsInOrder: package group ${n} names an unknown part`),t.sort((l,d)=>a.indexOf(l.partKey)-a.indexOf(d.partKey))}F(`Package run ${n} has no package reference.`)}s(ML,"groupRunsInOrder");function qL(e){return e.every(n=>n.status==="succeeded"&&n.contractId!==void 0&&n.contractSnapshotId!==void 0)}s(qL,"isCompleteGroup");var Iv=200;function O3(e){let n=e.generatorStamp?.parts;return n===void 0&&F(`groupChain: node "${e.id}" names no combined generator \u2014 only a combined generator keeps a group chain`),n.map(t=>t.partKey)}s(O3,"groupPartKeys");async function P3(e,n,t){let r=await e.db.query("contract_generation_runs").withIndex("by_applicationId_and_workflowNodeId",i=>i.eq("applicationId",n).eq("workflowNodeId",t)).take(Iv+1);return r.length>Iv&&F(`groupChain: more than ${Iv} generation runs on node ${t}`),r}s(P3,"nodeRuns");async function N3(e,n,t){let r=O3(t),i=new Set;for(let a of await P3(e,n,t.id))a.packageRunId===void 0&&F(`groupChain: run ${a._id} on the combined node "${t.id}" carries no generation group`),i.add(a.packageRunId);let o=[];for(let a of i){let l=await ML(e,a);if(!qL(l))continue;let d=await e.db.get(a);d===null&&F(`groupChain: generation group ${a} has no package run`);let c=new Set(Sm(d).map(p=>p.partKey)),u=[];for(let p of l){!r.includes(p.partKey)&&!c.has(p.partKey)&&F(`groupChain: run ${p._id} renders part "${p.partKey}", which node "${t.id}"'s pin does not declare and nobody added`);let m=await e.db.get(p.contractSnapshotId);m===null&&F(`groupChain: run ${p._id} names revision ${p.contractSnapshotId}, which is gone \u2014 a deleted draft lets its run go first`),u.push({run:p,snapshot:m})}o.push({packageRunId:a,startedAt:Math.min(...l.map(p=>p._creationTime)),members:u})}return o.sort((a,l)=>a.startedAt-l.startedAt)}s(N3,"groupRevisionRows");async function Ov(e,n,t){let r=await vm(e,{applicationId:n,nodeId:t,key:$s});return r.state==="pending"?[]:(r.ref.kind!=="contracts"&&F(`groupChain: $node.${t}.${$s} of application ${n} is a ${r.ref.kind} ref \u2014 the group chain writes a contracts ref`),[...r.ref.contracts])}s(Ov,"nodeGroupContracts");async function _3(e,n){let t=new Map;for(let{snapshot:r}of n.members){let i=await $v(e,r._id);i!==null&&t.set(i._id,i)}return t.size>1&&F(`groupChain: generation group ${n.packageRunId} is held by ${t.size} family Vorg\xE4nge \u2014 one Vorgang carries the group`),[...t.values()][0]??null}s(_3,"openGroupRequest");async function C3(e,n){let t=[];for(let i of await bv(e,n._id)){let o=await e.db.system.get("_storage",i.storageId);o===null&&F(`groupChain: return ${n._id} holds missing file ${i.storageId}`),t.push({contractSnapshotId:i.contractSnapshotId,storageId:i.storageId,filename:i.filename,...o.contentType!==void 0?{mimeType:o.contentType}:{}})}let r=t[0];return{_id:n._id,_creationTime:n._creationTime,storageId:r.storageId,filename:r.filename,...r.mimeType!==void 0?{mimeType:r.mimeType}:{},round:n._id,documents:t}}s(C3,"toGroupReturn");function KL(e){async function n(i,o,a,l){let d=(await N3(i,o,e)).find(c=>c.members[0]?.snapshot._id===a);return d===void 0&&F(`${l}: ${a} is no revision of node "${e.id}"'s generation groups \u2014 corrupt arc`),d}return s(n,"revisionRowOf"),{reads:{kind:"group",async returned(i,o,a){if(a.askedAbout===void 0){if(a.onUnpinned==="notReturned")return null;F(`returned(${a.where}): an ask of the group chain is always pinned to its lead revision`)}let l=await n(i,o,a.askedAbout,`returned(${a.where})`),d=await _3(i,l);if(d===null)return null;let c=(await km(i,d._id)).filter(u=>u.review.status==="pending"&&u._id!==a.rejected);return c.length>1&&F(`returned(${a.where}): Vorgang ${d._id} has ${c.length} returns pending \u2014 one is checked at a time`),c[0]===void 0?null:await C3(i,c[0])},pinOf(i){return i.contractSnapshotId},returnPinOf(i){return i.signingReturnId}},revisionRowOf:n,contractsOf:{async contractsOf(i,o){return(await Ov(i,o,e.id)).map(a=>a.contractId)}}.contractsOf}}s(KL,"groupNodeReads");async function D3(e,n){let t=n.lifecycle.kind==="draft"?void 0:n.lifecycle.kind;return{_id:n._id,_creationTime:n._creationTime,versionNumber:n.versionNumber,...t!==void 0?{status:t}:{},origin:n.origin.kind,storageId:n.storageId,...await bk(e,n.storageId),...n.filename!==void 0?{filename:n.filename}:{}}}s(D3,"toRevision");async function F3(e,n){let t=await D3(e,n);return{_id:t._id,_creationTime:t._creationTime,storageId:t.storageId,...t.filename!==void 0?{filename:t.filename}:{},...t.mimeType!==void 0?{mimeType:t.mimeType}:{},round:t.versionNumber}}s(F3,"toReturn");function jL(e){let n=hp(e);async function t(o,a){return await o.db.query("admission_documents").withIndex("by_applicationId_and_slotKey_and_versionNumber",l=>l.eq("applicationId",a).eq("slotKey",n)).collect()}return s(t,"contentRowsAsc"),{reads:{kind:"artifact",async returned(o,a,l){if(l.askedAbout===void 0){if(l.onUnpinned==="notReturned")return null;le("CONFLICT",{de:"Die offene Antwort-Aufgabe ist an keine Dokumentversion gebunden, daher l\xE4sst sich die unterschriebene Fassung nicht vom versandten Dokument unterscheiden. Stellen Sie das Dokument neu aus (Zur\xFCckziehen & neu ausstellen).",en:"The open response task is not bound to a document version, so the signed copy cannot be told apart from the document that was sent. Issue the document again (withdraw and reissue)."})}let d=await t(o,a),c=d[d.length-1];if(c===void 0||c._id===l.askedAbout||c.origin.kind!=="uploaded")return null;if(l.rejected!==void 0){let u=d.find(p=>p._id===l.rejected);if(u===void 0&&F(`returned(${l.where}): the handed-back scan ${l.rejected} is no version of slot "${n}"`),c.versionNumber<=u.versionNumber)return null}return await F3(o,c)},pinOf(o){return o.artifactVersionId},returnPinOf(o){return o.artifactVersionId}},contentRowsAsc:t,contractsOf:{async contractsOf(){return[]}}.contractsOf}}s(jL,"artifactNodeReads");function Am(e){return e.production==="none"&&F(`documentChainKind: node "${e.id}" has production 'none' \u2014 it keeps no document`),e.production!=="resolver"?"artifact":e.generatorStamp?.parts!==void 0?"group":"contract"}s(Am,"documentChainKind");function BL(e){switch(Am(e)){case"contract":return xm(e).reads;case"group":return KL(e).reads;case"artifact":return jL(e).reads}}s(BL,"documentReadsFor");var L3={de:"Haben Sie die Vertragsbedingungen gelesen und verstanden?",en:"Have you read and understood the contract terms?"};function Pd(e){let n=e.responseStrategy;return typeof n=="string"&&n in ci?ci[n].producesResponseArtifact:!1}s(Pd,"returnsSignedCopy");function M3(e){return Pd(e)&&e.confirmContractTerms!==!1}s(M3,"asksContractTerms");function VL(e){return M3(e)?{title:e.contractTermsQuestionText??L3,body:{de:"Die unterschriebene Fassung wird erst nach Ihrer Best\xE4tigung hochgeladen. Die Best\xE4tigung wird mit Zeitpunkt und Person festgehalten.",en:"The signed copy is uploaded only after you confirm. The confirmation is recorded with time and person."},confirmLabel:{de:"OK",en:"OK"}}:null}s(VL,"contractTermsConfirm");async function q3(e,n,t){if(t.revisesWorkItemId===void 0)return;let r=await e.db.get(t.revisesWorkItemId),i=r===null?null:cw(r),o=i?.context,a=o?.kind==="admission"?n.returnPinOf(o):void 0;return(i===null||o===void 0||o.kind!=="admission"||i.templateKey!==Kr||i.status!=="done"||i.outcome!=="rejected"||a===void 0)&&F(`rejectedReturnOfAsk: ask ${t._id} revises ${t.revisesWorkItemId}, which is not a rejected, pinned ${Kr} row`),a}s(q3,"rejectedReturnOfAsk");async function UL(e,n){return await n.chain.returned(e,n.applicationId,{askedAbout:n.chain.pinOf(n.ask),rejected:await q3(e,n.chain,n.ask),onUnpinned:n.onUnpinned,where:n.where})}s(UL,"returnedCopyOfAsk");var Pv=new Set([...Iw,qr,$o,Kr,ut]),YL={id:Vn,type:"contractGenerator",label:{de:"Vertragsgenerator",en:"Contract generator"},required:!0,inspector:"literal-only",optionSource:"tenantGenerators"},HL={id:ho,type:"documentTemplate",label:{de:"Dokumentvorlage",en:"Document template"},required:!0,inspector:"literal-only",optionSource:"tenantDocumentTemplates"};function K3(e){let n=[],t=[{slot:YL,production:"resolver",de:{a:"einen",the:"der",it:"ihn"}},{slot:HL,production:"template",de:{a:"eine",the:"die",it:"sie"}}];for(let{slot:r,production:i,de:o}of t){let a=e.inputs?.[r.id];if(a===void 0||a.kind==="unset")continue;let l=`inputs.${r.id}`;if(e.production!==i){n.push(Re(e,l,{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production '${e.production}', nennt aber ${o.a} ${r.label.de} \u2014 nur production '${i}' verwendet sie.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production '${e.production}' but names a ${r.label.en.toLowerCase()} \u2014 only production '${i}' uses it.`}));continue}if(a.kind==="binding"){n.push(Re(e,l,{de:`[governedDocument/referenceNotLiteral] Knoten "${e.id}": ${o.the} ${r.label.de} ist ein fester Wert des Knotens, keine Bindung \u2014 w\xE4hlen Sie ${o.it} aus.`,en:`[governedDocument/referenceNotLiteral] Node "${e.id}": the ${r.label.en.toLowerCase()} is a fixed value of the node, not a binding \u2014 choose it from the list.`}));continue}if(a.kind!=="literal")continue;let d=xl(a.value,{type:r.type});d!==null&&n.push(Re(e,l,{de:`[governedDocument/referenceShape] Knoten "${e.id}": ${d}.`,en:`[governedDocument/referenceShape] Node "${e.id}": ${d}.`}))}return n}s(K3,"referenceInputIssues");var j3={id:di,type:"number",label:{de:"Antwortfrist (Tage)",en:"Answer within (days)"},inspector:"literal-only"},B3={id:_t,type:"legalEntity",label:e_,required:!0,inspector:"literal-only",optionSource:"tenantTraeger"};function V3(e,n){let t=`inputs.${_t}`,r=e.inputs?.[_t];if(r!==void 0&&r.kind==="binding")return[Re(e,t,{de:`[governedDocument/traegerNotLiteral] Knoten "${e.id}": der Tr\xE4ger ist ein fester Wert des Knotens, keine Bindung \u2014 w\xE4hlen Sie ihn aus.`,en:`[governedDocument/traegerNotLiteral] Node "${e.id}": the legal entity is a fixed value of the node, not a binding \u2014 choose it from the list.`})];let i=Xs(e),o=n?.resolverPrintsTraegerAddress?.get(e.id)??new Set,a=[];for(let l of new Set([...i===null?[]:[i],...o])){let d=n?.traeger?.get(l);n?.traeger!==void 0&&d===void 0?a.push(Re(e,t,{de:`[governedDocument/unknownTraeger] Knoten "${e.id}" nennt den Tr\xE4ger "${l}", den es in diesem Mandanten nicht gibt \u2014 bekannt: ${[...n.traeger.keys()].join(", ")||"(keiner)"}.`,en:`[governedDocument/unknownTraeger] Node "${e.id}" names the legal entity "${l}", which does not exist in this school \u2014 known: ${[...n.traeger.keys()].join(", ")||"(none)"}.`})):d!==void 0&&!d.hasAddress&&o.has(l)&&a.push(Re(e,t,{de:`[governedDocument/traegerAddressMissing] Die Vorlage des Generators an Knoten "${e.id}" druckt die Anschrift des Tr\xE4gers (${ap.address}), aber "${l}" hat keine \u2014 in der Konfiguration des Mandanten nachtragen (foundation.legalEntities[].address).`,en:`[governedDocument/traegerAddressMissing] The generator template on node "${e.id}" prints the legal entity's address (${ap.address}), but "${l}" has none \u2014 add it in the school's configuration (foundation.legalEntities[].address).`}))}return a}s(V3,"traegerIssues");function Tm(e){if(e.production==="template"){let t=e.templateStamp?.fields;return Array.isArray(t)?t:[]}if(e.production!=="resolver")return[];let n=e.generatorStamp?.inputSchema?.fields;return Array.isArray(n)?n.map(t=>{let{label:r}=t;return r===void 0?{...t,label:{de:t.key,en:t.key}}:($i(r)||F(`governedDocument "${e.id}": the stamped generator parameter "${t.key}" has no { de, en } label (${JSON.stringify(r)}) \u2014 rebuild local fixtures or obtain a reviewed repair of this retained workflow stamp.`),{...t,label:r})}):[]}s(Tm,"generatorFields");function U3(e,n){return e.inputs?.[n]?.kind==="cockpit"}s(U3,"deferredToCockpit");function G3(e){return _i(e.type)?e.type:void 0}s(G3,"resolverSlotType");function z3(e){if(e.confirmBeforeIssue!==!0||e.approval!=="none")return null;let n=Kl(e);return{confirm:{title:{de:`\u201E${n.de}\u201C jetzt senden?`,en:`Send "${n.en}" now?`},body:{de:"Das Dokument wird danach f\xFCr die Familie sichtbar.",en:"The family will be able to see the document afterwards."},confirmLabel:{de:"Senden",en:"Send"}}}}s(z3,"issueConfirmation");function Re(e,n,t){return{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${n}`,reason:t,severity:"error"}}s(Re,"issue");function Em(e){return up.includes(e.production)&&Po.includes(e.approval)&&pp.includes(e.responseStrategy)}s(Em,"hasValidModes");async function Nv(e,n){let t=await Pl(e,{applicationId:n.applicationId,nodeId:n.node.id});if(t.length===0)return"pending";let r=t.filter(l=>l.isOpen&&l.kind==="admission"),i=r.filter(l=>l.templateKey!==void 0&&Iw.has(l.templateKey));if(i.length>0)return i.every(l=>l.status==="blocked")?"producingHeld":"producing";let o=r.find(l=>l.templateKey===qr);if(o!==void 0)return o.status==="blocked"?"deferred":"awaitingApproval";if(r.some(l=>l.templateKey===ut))return"signatureStalled";let a=r.find(l=>l.templateKey===$o);if(a!==void 0){if(Bi(n.node).issuesBy==="provider"){let d=Am(n.node)==="group"?(await Ov(e,n.applicationId,n.node.id)).map(c=>c.contractId):[await xm(n.node).contractOrNull(e,n.applicationId)].flatMap(c=>c===null?[]:[c]);if(d.length===0&&F(`governedDocCurrentState: eSignature node "${n.node.id}" has an open ask but no contract`),await LL(e,d)==="provider")return"awaitingSignature"}return Bi(n.node).producesResponseArtifact?await UL(e,{chain:BL(n.node),applicationId:n.applicationId,ask:a,onUnpinned:"notReturned",where:`governedDocCurrentState(node "${n.node.id}")`})===null?"awaitingResponse":"responseReturned":"awaitingResponse"}return r.some(l=>l.templateKey===Kr)?"responseInCheck":"done"}s(Nv,"governedDocCurrentState");function GL(e){return e.production!=="none"&&Am(e)!=="artifact"}s(GL,"keepsDocumentInContractDomain");function W3(e,n){let t=e.inputs?.[n.key];if(t?.kind!=="binding")return[];let r=t.address;if(!we(r)||r.scope!=="env"||!Wt(r.key))return[];let i=mo(r.key);if(n.type!==i.type)return[Re(e,`inputs.${n.key}`,{de:`[governedDocument/envNotCovered] Feld "${n.key}" ist ${n.type}, die Umgebungsvariable \u201E${i.label.de}\u201C (${se(r)}) liefert ${i.type}.`,en:`[governedDocument/envNotCovered] Field "${n.key}" is ${n.type}, the environment variable "${i.label.en}" (${se(r)}) supplies ${i.type}.`})];let o=new Set((n.options??[]).map(l=>l.value)),a=(i.enumOptions??[]).filter(l=>!o.has(l.value));return a.length===0?[]:[Re(e,`inputs.${n.key}`,{de:`[governedDocument/envNotCovered] Feld "${n.key}" kennt ${a.map(l=>`\u201E${l.label.de}\u201C (${l.value})`).join(", ")} nicht \u2014 die Umgebungsvariable \u201E${i.label.de}\u201C kann diese Werte liefern. Jeder Wert braucht eine Option.`,en:`[governedDocument/envNotCovered] Field "${n.key}" does not know ${a.map(l=>`"${l.label.en}" (${l.value})`).join(", ")} \u2014 the environment variable "${i.label.en}" can supply these values. Every value needs an option.`})]}s(W3,"envCoverageIssues");function JL(e,n){let t=[];for(let r of Tm(e)){if(r.type==="party"||r.type==="personList")continue;if(t.push(...W3(e,r)),r.processSource!==void 0){let a=e.inputs?.[r.key],l=a?.kind==="binding"?{de:`eine Bindung an ${we(a.address)?se(a.address):JSON.stringify(a.address)}`,en:`a binding to ${we(a.address)?se(a.address):JSON.stringify(a.address)}`}:a?.kind==="literal"?{de:"ein fester Wert",en:"a fixed value"}:U3(e,r.key)?{de:"eine Erg\xE4nzung im Cockpit",en:"a completion in the cockpit"}:null;l!==null&&t.push({layer:"GRAPH",kind:"contractGap",path:`nodes.${e.id}.inputs.${r.key}`,reason:{de:`[governedDocument/processSourceConflict] "${r.label.de}" wird vom Vorgang selbst gef\xFCllt (${r.processSource}), daneben steht ${l.de}. Eine der beiden Quellen bliebe wirkungslos \u2014 entferne die Verdrahtung.`,en:`[governedDocument/processSourceConflict] "${r.label.en}" is filled by the case itself (${r.processSource}), and ${l.en} is set as well. One of the two sources would have no effect \u2014 remove the wiring.`},severity:"error"});continue}if(r.required!==!0)continue;let i=e.inputs?.[r.key];i?.kind==="binding"||i?.kind==="literal"||i?.kind==="cockpit"||r.defaultValue!==void 0||t.push({layer:"GRAPH",kind:"contractGap",path:`nodes.${e.id}.inputs.${r.key}`,reason:{de:`[governedDocument/unsourcedRequiredField] Pflichtfeld "${r.label.de}" des Generators ${n.de} hat keine Quelle \u2014 binde es an ein Formular-Export-Feld, setze einen festen Wert oder lass es ausdr\xFCcklich im Cockpit erg\xE4nzen.`,en:`[governedDocument/unsourcedRequiredField] Required field "${r.label.en}" of the generator ${n.en} has no source \u2014 bind it to a form export field, set a fixed value or leave it explicitly to the cockpit.`},severity:"error"})}return t}s(JL,"fieldSourceIssues");function Y3(e){let n=pr(e)??"\u2014";if(e.templateStamp===void 0)return[];let t=AL(e.templateStamp,n).map(({path:r,reason:i})=>Re(e,r===""?"templateStamp":`templateStamp.${r}`,i));return t.push(...JL(e,{de:`Vorlage "${n}"`,en:`template "${n}"`})),t}s(Y3,"templateIssues");function H3(e,n){return(n?.resolverDocumentAnchors?.get(e.id)??[]).flatMap(t=>{if(t.documentAnchors===null)return[Re(e,"resolver",{de:`[governedDocument/eSignatureAnchorMissing] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben, aber die Vorlage des Generators "${t.pin}" wurde nie auf Unterschriftsanker gelesen \u2014 Vorlage neu hochladen und den Generator neu versiegeln.`,en:`[governedDocument/eSignatureAnchorMissing] Node "${e.id}" is signed electronically, but the generator template "${t.pin}" was never read for signature anchors \u2014 upload the template again and seal the generator again.`})];let r=t.signerAnchors.filter(i=>!t.documentAnchors.has(i));return r.length===0?[]:[Re(e,"resolver",{de:`[governedDocument/eSignatureAnchorMissing] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben, aber die Vorlage von "${t.pin}" tr\xE4gt keinen Anker f\xFCr ${r.map(i=>`/unterschrift:${i}/`).join(", ")} \u2014 der Anbieter f\xE4nde f\xFCr diese Personen kein Unterschriftsfeld.`,en:`[governedDocument/eSignatureAnchorMissing] Node "${e.id}" is signed electronically, but the template of "${t.pin}" has no anchor for ${r.map(i=>`/unterschrift:${i}/`).join(", ")} \u2014 the provider would find no signature field for these people.`})]})}s(H3,"eSignatureAnchorIssues");function J3(e,n){return n===void 0||n.sendable?[]:Bi(e).issuesBy!=="provider"?[]:[Re(e,"responseStrategy",{de:`[signing/noActiveProvider] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben, aber die Schule kann nicht senden: ${n.reason.de}`,en:`[signing/noActiveProvider] Node "${e.id}" is signed electronically, but the school cannot send: ${n.reason.en}`})]}s(J3,"eSignatureProviderIssues");var zL={key:"dokument",label:te("Dokument","Document"),scope:"node"},WL={producing:{label:te("Dokument in Vorbereitung","Document in preparation"),tone:"blue",phase:zL,external:en(te("In Vorbereitung","In preparation"),"blue",te("Ihr Dokument wird vorbereitet","Your document is being prepared"),te("Die Schule erstellt Ihr Dokument. Sie erhalten es in K\xFCrze im Portal.","The school is preparing your document. You will receive it in the portal shortly."))},issued:{label:te("Dokument bereitgestellt","Document issued"),tone:"blue",phase:zL,external:en(te("Dokument bereit","Document ready"),"amber",te("Ihr Dokument liegt bereit","Your document is ready"),te("Bitte beantworten Sie das Dokument innerhalb der Frist. Sie finden es in Ihren Aufgaben.","Please respond to the document within the deadline. You will find it in your tasks."),te("Dokument beantworten","Respond to the document"))}},QL={role:"user-action",effect:"side-effect",processHoldTemplate:s(()=>To,"processHoldTemplate"),progressDefaults:WL,progressEvents:Mn(WL),notificationEvents:s(e=>[{id:"issued",label:{de:"Dokument bereitgestellt",en:"Document issued"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"documentTitle",type:"localizedText",required:!0},{key:"dueInDays",type:"number"}]},{id:"responded",label:{de:"Antwort eingegangen",en:"Response received"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"documentTitle",type:"localizedText",required:!0}]},{id:"responseRejected",label:{de:"R\xFCcklauf zur\xFCckgegeben",en:"Returned copy handed back"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"documentTitle",type:"localizedText",required:!0},{key:"reason",type:"string",required:!0}]}],"notificationEvents"),strictActionCoverage:!0,actions:s(e=>{if(!Em(e))return[];let n=Bi(e),t=[],r=n.producesResponseArtifact?["awaitingResponse","responseReturned"]:["awaitingResponse"],i=n.issuesBy==="provider"?["awaitingSignature","signatureStalled",...r]:r,o=n.checksReturn?[...i,"responseInCheck"]:i;return e.production!=="none"&&(t.push({id:Pw(e),kind:"internal",surface:ea,label:e.approval==="release"?{de:"Freigabe anfordern",en:"Request approval"}:{de:"Bereitstellen",en:"Issue document"},availableIn:["producing","producingHeld"],...z3(e)??{}}),t.push({id:i_,kind:"internal",surface:ea,label:{de:"Korrigieren",en:"Correct"},availableIn:o,superUserOnly:!0},{id:o_,kind:"internal",surface:ea,label:{de:"Zur\xFCckziehen & neu ausstellen",en:"Rescind & re-issue"},availableIn:o,superUserOnly:!0})),t.push(n.checksReturn?{id:lp,kind:"internal",label:e.responseLabels?.accept??n.defaultLabels.accept,availableIn:[r[r.length-1]],external:{emphasis:"primary",event:"documentReturned"}}:{id:n.acceptOutcomeId,kind:"advance",outcome:n.acceptOutcomeId,semantic:n.outcomeSemantics.accept,label:e.responseLabels?.accept??n.defaultLabels.accept,availableIn:[r[r.length-1]],external:{emphasis:"primary",event:"userTaskResolved"}},{id:n.declineOutcomeId,kind:"advance",outcome:n.declineOutcomeId,semantic:n.outcomeSemantics.decline,label:e.responseLabels?.decline??n.defaultLabels.decline,availableIn:i,external:{emphasis:"decline",event:"userTaskResolved"}}),n.producesResponseArtifact&&t.push({id:dp,kind:"internal",label:{de:"\xC4nderung anfordern",en:"Request a change"},availableIn:i,external:{emphasis:"secondary",event:"documentChangeRequested"}}),n.issuesBy==="provider"&&t.push({id:cp,kind:"internal",surface:ea,label:{de:"Erneut senden",en:"Send again"},availableIn:["signatureStalled"]},{id:Ro,kind:"internal",surface:ea,label:{de:"Auf Papier umstellen",en:"Switch to paper"},availableIn:["signatureStalled"]}),t},"actions"),states:s_,currentState:Nv,workItemTemplates:s(e=>{let n=e;return Em(n)?Nw(n):[]},"workItemTemplates"),taskDocuments:s((e,n)=>{let t=e;if(!Em(t)||t.production==="none")return[];let r=Nw(t).find(i=>i.key===n);return r===void 0||r.recipient!=="internal"?[]:[{kind:"artifact",key:hp(t)}]},"taskDocuments"),inputs:s(e=>[...e.production==="resolver"?[YL,B3]:[],...e.production==="template"?[HL]:[],j3,...Tm(e).filter(n=>n.type!=="party"&&n.type!=="personList").flatMap(n=>{let t=G3(n);return t===void 0?[]:[{field:n,type:t}]}).map(({field:n,type:t})=>({id:n.key,type:t,label:n.label,required:n.required===!0&&n.processSource===void 0,...n.processSource===void 0?{deferrable:!0}:{},...n.defaultValue!==void 0&&(typeof n.defaultValue=="string"||typeof n.defaultValue=="number"||typeof n.defaultValue=="boolean"||n.defaultValue===null||t==="pricedItem"&&Oi(n.defaultValue))?{defaultValue:n.defaultValue}:{},...n.options!==void 0?{enumOptions:n.options}:{}}))],"inputs"),outputs:s(e=>e.production==="none"?[]:[{name:wl,type:"documentRef",label:{de:"Dokument",en:"Document"}}],"outputs"),refuseBlocksTarget:s((e,n)=>{if(n===$o||n===Ml||n===Kr||n===ut){let t=n===$o?{de:"die Antwort-Aufgabe geh\xF6rt dem Empf\xE4nger",en:"the response task belongs to the recipient"}:n===Kr?{de:"die Pr\xFCfung des R\xFCcklaufs entsteht erst mit dem R\xFCcklauf der Familie",en:"the check of the returned copy only arises once the family returns it"}:n===ut?{de:"die Kl\xE4rung der elektronischen Unterschrift entsteht erst, wenn sie nicht zustande kommt",en:"resolving the electronic signature only arises when it does not come about"}:{de:"die \xDCberarbeitungs-Aufgabe entsteht nur durch eine Ablehnung",en:"the revision task only arises from a rejection"};return{de:`[governedDocument/blocksTarget] 'blocks' auf "${n}" (Knoten "${e.id}") ist verboten \u2014 ${t.de}; zul\xE4ssige intrinsische Ziele: ${To}${e.approval==="release"?`, ${qr}`:""}.`,en:`[governedDocument/blocksTarget] 'blocks' on "${n}" (node "${e.id}") is not allowed \u2014 ${t.en}; allowed intrinsic targets: ${To}${e.approval==="release"?`, ${qr}`:""}.`}}return n===qr&&e.approval==="none"?{de:`[governedDocument/blocksTarget] 'blocks' auf "${qr}" auf Knoten "${e.id}" \u2014 mit approval 'none' existiert dieses Template nicht; der Blocker w\xFCrde ein Phantom aufschieben.`,en:`[governedDocument/blocksTarget] 'blocks' on "${qr}" on node "${e.id}" \u2014 with approval 'none' this template does not exist; the blocker would postpone a phantom.`}:null},"refuseBlocksTarget"),userUploadGate:s(async(e,n)=>{if(GL(n.node))return!1;let t=await Nv(e,n),r=(t==="awaitingResponse"||t==="responseReturned")&&Bi(n.node).producesResponseArtifact;return n.actor==="recipient"?r:t==="producing"&&n.node.production==="upload"||r},"userUploadGate"),userUploadConfirmation:s(async(e,n)=>{let t=VL(n.node);if(t===null||GL(n.node))return null;let r=await Nv(e,n);return r==="awaitingResponse"||r==="responseReturned"?t:null},"userUploadConfirmation"),validate:s((e,n,t)=>{let r=[];if(!Em(e))return r.push(Re(e,"modes",{de:`[governedDocument/unknownMode] Knoten "${e.id}" deklariert keine g\xFCltige Betriebsart \u2014 erforderlich: production \u2208 {${up.join(", ")}} (ist: ${JSON.stringify(e.production)}), approval \u2208 {${Po.join(", ")}} (ist: ${JSON.stringify(e.approval)}), responseStrategy \u2208 {${pp.join(", ")}} (ist: ${JSON.stringify(e.responseStrategy)}). Eine Betriebsart ist eine erkl\xE4rte Entscheidung, nie aus der Verdrahtung abgeleitet.`,en:`[governedDocument/unknownMode] Node "${e.id}" declares no valid mode \u2014 required: production \u2208 {${up.join(", ")}} (is: ${JSON.stringify(e.production)}), approval \u2208 {${Po.join(", ")}} (is: ${JSON.stringify(e.approval)}), responseStrategy \u2208 {${pp.join(", ")}} (is: ${JSON.stringify(e.responseStrategy)}). A mode is a declared decision, never derived from the wiring.`})),r;let i=ci[e.responseStrategy];e.production==="none"&&(e.approval!=="none"||e.responseStrategy!=="confirm")&&r.push(Re(e,"production",{de:`[governedDocument/modeContract] Knoten "${e.id}" hat production 'none' \u2014 ohne Dokument gibt es nichts freizugeben und nichts zu unterschreiben: approval muss 'none' sein (ist: '${e.approval}') und responseStrategy 'confirm' (ist: '${e.responseStrategy}').`,en:`[governedDocument/modeContract] Node "${e.id}" has production 'none' \u2014 with no document there is nothing to release and nothing to sign: approval must be 'none' (is: '${e.approval}') and responseStrategy 'confirm' (is: '${e.responseStrategy}').`}));let o=e.artifacts??[];if(e.production==="none")o.length!==0&&r.push(Re(e,"artifacts",{de:`[governedDocument/slotContract] Knoten "${e.id}" hat production 'none', deklariert aber ${o.length} Artefakt-Slot(s) \u2014 ein dokumentloser Best\xE4tigungs-Knoten verwaltet keinen Slot.`,en:`[governedDocument/slotContract] Node "${e.id}" has production 'none' but declares ${o.length} artifact slot(s) \u2014 a confirmation node without a document manages no slot.`}));else{o.length!==1&&r.push(Re(e,"artifacts",{de:`[governedDocument/slotContract] Knoten "${e.id}" deklariert ${o.length} Artefakt-Slots \u2014 genau EINER (das verwaltete Dokument) ist erforderlich.`,en:`[governedDocument/slotContract] Node "${e.id}" declares ${o.length} artifact slots \u2014 exactly ONE (the managed document) is required.`}));for(let v of o)v.visibility!=="external"&&r.push(Re(e,"artifacts",{de:`[governedDocument/slotContract] Slot "${v.key}" auf Knoten "${e.id}" hat visibility "${v.visibility}" \u2014 das verwaltete Dokument MUSS 'external' sein, sonst kann die bewerbende Person es auf /e nie sehen.`,en:`[governedDocument/slotContract] Slot "${v.key}" on node "${e.id}" has visibility "${v.visibility}" \u2014 the managed document MUST be 'external', otherwise the applicant can never see it on /e.`}))}let a=e.outcomes??[],l=a.map(v=>v.id),d=[i.acceptOutcomeId,i.declineOutcomeId];(a.length!==2||!d.every(v=>l.includes(v)))&&r.push(Re(e,"outcomes",{de:`[governedDocument/outcomeContract] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') muss genau ZWEI Outcomes deklarieren \u2014 das Accept-Terminal "${i.acceptOutcomeId}" und das Decline-Terminal "${i.declineOutcomeId}" (deklariert: ${l.length>0?l.map(v=>`"${v}"`).join(", "):"keine"}). Beide sind Pflicht: der Knoten besitzt die Antwort, nicht nur die Freigabe.`,en:`[governedDocument/outcomeContract] Node "${e.id}" (responseStrategy '${e.responseStrategy}') must declare exactly TWO outcomes \u2014 the accept terminal "${i.acceptOutcomeId}" and the decline terminal "${i.declineOutcomeId}" (declared: ${l.length>0?l.map(v=>`"${v}"`).join(", "):"none"}). Both are required: the node owns the answer, not only the release.`}));let c=e.titles,u=s(v=>{let E=c?.[v];return E===null||typeof E!="object"||!Object.values(E??{}).some(A=>typeof A=="string"&&A.length>0)},"missingTitle"),p=[];e.production!=="none"&&p.push("prepare","revise"),e.approval==="release"&&p.push("approve"),i.checksReturn&&p.push("check");let m=p.filter(u);m.length>0&&r.push(Re(e,"titles",{de:`[governedDocument/missingTitles] Knoten "${e.id}" fehlen die Aufgaben-Titel ${m.join(", ")} \u2014 der Knotentyp ist dokument-agnostisch, die Betitelung ist Pflicht-Konfiguration seiner Betriebsart.`,en:`[governedDocument/missingTitles] Node "${e.id}" is missing the task titles ${m.join(", ")} \u2014 the node type is document-agnostic, titling is required configuration of its mode.`}));let y=e.assign??{};if(e.production!=="none"){let v=y.prepareDocument;(typeof v!="string"||v.length===0)&&r.push(Re(e,"assign.prepareDocument",{de:`[governedDocument/productionAssign] Knoten "${e.id}" (production '${e.production}') verdrahtet kein Produzenten-Team (assign.prepareDocument) \u2014 ohne Producer-Aufgabe g\xE4be es die Submit-Aktion ohne freischaltendes Work-Item.`,en:`[governedDocument/productionAssign] Node "${e.id}" (production '${e.production}') wires no producer team (assign.prepareDocument) \u2014 without a producer task there would be the submit action without an enabling work item.`}))}if(e.approval==="none"&&(y.releaseApproval!==void 0&&r.push(Re(e,"assign.releaseApproval",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat approval 'none', verdrahtet aber assign.releaseApproval \u2014 tote Verdrahtung darf nicht als konfiguriert durchgehen (Betriebsart explizit \xE4ndern statt Gruppen zuweisen).`,en:`[governedDocument/deadWiring] Node "${e.id}" has approval 'none' but wires assign.releaseApproval \u2014 dead wiring must not pass as configured (change the mode explicitly instead of assigning groups).`})),c?.approve!==void 0&&r.push(Re(e,"titles.approve",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat approval 'none', deklariert aber titles.approve \u2014 es gibt keine Freigabe-Aufgabe, die diesen Titel tr\xFCge.`,en:`[governedDocument/deadWiring] Node "${e.id}" has approval 'none' but declares titles.approve \u2014 there is no release task that would carry this title.`}))),i.checksReturn){let v=y.responseCheck;(typeof v!="string"||v.length===0)&&r.push(Re(e,"assign.responseCheck",{de:`[governedDocument/checkAssign] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') verdrahtet kein Team f\xFCr die Pr\xFCfung des R\xFCcklaufs (assign.responseCheck) \u2014 ohne Team l\xE4ge jeder R\xFCcklauf bei niemandem.`,en:`[governedDocument/checkAssign] Node "${e.id}" (responseStrategy '${e.responseStrategy}') wires no team for checking the returned copy (assign.responseCheck) \u2014 without a team every returned copy would lie with nobody.`})),e.production!=="resolver"&&i.issuesBy==="provider"?r.push(Re(e,"responseStrategy",{de:`[governedDocument/eSignatureNeedsResolver] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben (eSignature), erzeugt das Dokument aber mit production '${e.production}' \u2014 der Anbieter bekommt eine eingefrorene Vertragsrevision mit Unterschriftsankern und deklarierten Unterzeichnern, und die entsteht nur mit production 'resolver'.`,en:`[governedDocument/eSignatureNeedsResolver] Node "${e.id}" is signed electronically (eSignature) but produces the document with production '${e.production}' \u2014 the provider gets a frozen contract revision with signature anchors and declared signatories, and that only exists with production 'resolver'.`})):e.production!=="resolver"&&r.push(Re(e,"responseStrategy",{de:`[governedDocument/checkNeedsContract] Knoten "${e.id}" pr\xFCft den R\xFCcklauf (signedUploadChecked), erzeugt das Dokument aber mit production '${e.production}' \u2014 die Pr\xFCfung hakt die unterzeichnenden Personen einer eingefrorenen Vertragsrevision ab, und die entsteht nur mit production 'resolver'.`,en:`[governedDocument/checkNeedsContract] Node "${e.id}" checks the returned copy (signedUploadChecked) but produces the document with production '${e.production}' \u2014 the check ticks off the signatories of a frozen contract revision, and that only exists with production 'resolver'.`}))}else{e.production==="resolver"&&r.push(Re(e,"responseStrategy",{de:`[governedDocument/contractNeedsCheckedReturn] Knoten "${e.id}" erzeugt einen Vertrag (production 'resolver'), beantwortet ihn aber mit '${e.responseStrategy}' \u2014 ein Vertrag gilt erst als unterschrieben, wenn die Schule den R\xFCcklauf gepr\xFCft hat oder ein Anbieter die Unterschrift belegt: responseStrategy muss 'signedUploadChecked' oder 'eSignature' sein (mit assign.responseCheck und titles.check).`,en:`[governedDocument/contractNeedsCheckedReturn] Node "${e.id}" produces a contract (production 'resolver') but answers it with '${e.responseStrategy}' \u2014 a contract only counts as signed once the school has checked the returned copy or a provider proves the signature: responseStrategy must be 'signedUploadChecked' or 'eSignature' (with assign.responseCheck and titles.check).`}));for(let[v,E]of[["assign.responseCheck",y.responseCheck!==void 0],["titles.check",c?.check!==void 0]])E&&r.push(Re(e,v,{de:`[governedDocument/deadWiring] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') deklariert ${v} \u2014 eine Pr\xFCfung des R\xFCcklaufs gibt es nur mit responseStrategy 'signedUploadChecked' oder 'eSignature'.`,en:`[governedDocument/deadWiring] Node "${e.id}" (responseStrategy '${e.responseStrategy}') declares ${v} \u2014 a check of the returned copy only exists with responseStrategy 'signedUploadChecked' or 'eSignature'.`}))}if(i.issuesBy==="provider"){let v=y.signingRecovery;(typeof v!="string"||v.length===0)&&r.push(Re(e,"assign.signingRecovery",{de:`[governedDocument/recoveryAssign] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben, verdrahtet aber kein Team f\xFCr die Kl\xE4rung einer Unterschrift, die nicht zustande kommt (assign.signingRecovery) \u2014 \u201EErneut senden" und \u201EAuf Papier umstellen" l\xE4gen bei niemandem.`,en:`[governedDocument/recoveryAssign] Node "${e.id}" is signed electronically but wires no team for resolving a signature that does not come about (assign.signingRecovery) \u2014 "Send again" and "Switch to paper" would lie with nobody.`}))}else y.signingRecovery!==void 0&&r.push(Re(e,"assign.signingRecovery",{de:`[governedDocument/deadWiring] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') deklariert assign.signingRecovery \u2014 eine Kl\xE4rung der elektronischen Unterschrift gibt es nur mit responseStrategy 'eSignature'.`,en:`[governedDocument/deadWiring] Node "${e.id}" (responseStrategy '${e.responseStrategy}') declares assign.signingRecovery \u2014 resolving an electronic signature only exists with responseStrategy 'eSignature'.`}));if(i.issuesBy==="provider"&&r.push(...H3(e,t),...J3(e,t?.signingProvider)),e.confirmBeforeIssue!==void 0&&typeof e.confirmBeforeIssue!="boolean"?r.push(Re(e,"confirmBeforeIssue",{de:`[governedDocument/confirmBeforeIssue] Knoten "${e.id}" setzt confirmBeforeIssue auf ${JSON.stringify(e.confirmBeforeIssue)} \u2014 erlaubt ist nur true oder false.`,en:`[governedDocument/confirmBeforeIssue] Node "${e.id}" sets confirmBeforeIssue to ${JSON.stringify(e.confirmBeforeIssue)} \u2014 only true or false is allowed.`})):e.confirmBeforeIssue===!0&&e.approval==="release"&&r.push(Re(e,"confirmBeforeIssue",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat approval 'release', deklariert aber confirmBeforeIssue \u2014 \u201EFreigabe anfordern" schickt noch nichts an die Familie, und die Freigabe selbst ist die bewusste Pr\xFCfung vor dem Versand. Die R\xFCckfrage gibt es nur mit approval 'none'.`,en:`[governedDocument/deadWiring] Node "${e.id}" has approval 'release' but declares confirmBeforeIssue \u2014 "Request release" sends nothing to the family yet, and the release itself is the deliberate check before sending. The confirmation prompt only exists with approval 'none'.`})),e.confirmContractTerms!==void 0&&typeof e.confirmContractTerms!="boolean"&&r.push(Re(e,"confirmContractTerms",{de:`[governedDocument/confirmContractTerms] Knoten "${e.id}" setzt confirmContractTerms auf ${JSON.stringify(e.confirmContractTerms)} \u2014 erlaubt ist nur true oder false.`,en:`[governedDocument/confirmContractTerms] Node "${e.id}" sets confirmContractTerms to ${JSON.stringify(e.confirmContractTerms)} \u2014 only true or false is allowed.`})),Pd(e))e.confirmContractTerms===!1&&e.contractTermsQuestionText!==void 0&&r.push(Re(e,"contractTermsQuestionText",{de:`[governedDocument/deadWiring] Knoten "${e.id}" schaltet die Best\xE4tigung der Vertragsbedingungen ab (confirmContractTerms: false), formuliert aber die Frage um \u2014 ohne Best\xE4tigung wird sie nie gestellt.`,en:`[governedDocument/deadWiring] Node "${e.id}" switches off the confirmation of the contract terms (confirmContractTerms: false) but rewords the question \u2014 without the confirmation it is never asked.`}));else for(let[v,E]of[["confirmContractTerms",e.confirmContractTerms!==void 0],["contractTermsQuestionText",e.contractTermsQuestionText!==void 0]])E&&r.push(Re(e,v,{de:`[governedDocument/deadWiring] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') deklariert ${v} \u2014 die Best\xE4tigung der Vertragsbedingungen geh\xF6rt zum Hochladen der unterschriebenen Fassung, das es nur mit responseStrategy 'signedUpload' oder 'signedUploadChecked' gibt.`,en:`[governedDocument/deadWiring] Node "${e.id}" (responseStrategy '${e.responseStrategy}') declares ${v} \u2014 the confirmation of the contract terms belongs to uploading the signed copy, which only exists with responseStrategy 'signedUpload' or 'signedUploadChecked'.`}));if(e.production==="none")for(let[v,E]of[["confirmBeforeIssue",e.confirmBeforeIssue===!0],["assign.prepareDocument",y.prepareDocument!==void 0],["titles.prepare",c?.prepare!==void 0],["titles.revise",c?.revise!==void 0]])E&&r.push(Re(e,v,{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production 'none', deklariert aber ${v} \u2014 ohne Produktionsphase gibt es keinen Tr\xE4ger daf\xFCr.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production 'none' but declares ${v} \u2014 without a production phase there is nothing to carry it.`}));for(let v of e.tasks??[])Pv.has(v.key)&&r.push(Re(e,`tasks.${v.key}`,{de:`[governedDocument/keyShadowsIntrinsic] Task-Key "${v.key}" auf Knoten "${e.id}" kollidiert mit einem intrinsischen Template (${[...Pv].join(", ")}) \u2014 anderen Key w\xE4hlen.`,en:`[governedDocument/keyShadowsIntrinsic] Task key "${v.key}" on node "${e.id}" collides with an intrinsic template (${[...Pv].join(", ")}) \u2014 choose another key.`}));if(e.production==="resolver"?r.push(...V3(e,t)):e.inputs?.[_t]!==void 0&&r.push(Re(e,`inputs.${_t}`,{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production '${e.production}', nennt aber einen Tr\xE4ger \u2014 nur ein erzeugter Vertrag hat eine Vertragspartei der Schule.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production '${e.production}' but names a legal entity \u2014 only a generated contract has a contracting party on the school's side.`})),r.push(...K3(e)),e.production==="resolver"){let v=ni(e);if(v!==null){let E=lI(v);for(let A of Tm(e)){if(!_i(A.type)){r.push(Re(e,`generatorStamp.inputSchema.${A.key}`,{de:`[governedDocument/unknownFieldType] Generator "${E}" typisiert das Feld "${A.key}" als "${String(A.type)}" \u2014 das geh\xF6rt nicht zum Wert-Vokabular der Plattform (${Os.join(", ")}). Die gepinnte Revision stammt aus einer \xE4lteren Fassung und muss neu versiegelt werden.`,en:`[governedDocument/unknownFieldType] Generator "${E}" types the field "${A.key}" as "${String(A.type)}" \u2014 that is not part of the platform's value vocabulary (${Os.join(", ")}). The pinned revision comes from an older version and must be sealed again.`}));continue}if(A.type==="personList"){r.push(Re(e,`generatorStamp.inputSchema.${A.key}`,{de:`[governedDocument/partyListUnsupported] Generator "${E}" deklariert das Feld "${A.key}" als personList \u2014 daf\xFCr gibt es keine Platzhalter-Heimat im Dokument und keine Eingabe. Eine Liste von Personen geh\xF6rt als Rolle mit Kapazit\xE4t deklariert oder als berechneter Textwert.`,en:`[governedDocument/partyListUnsupported] Generator "${E}" declares the field "${A.key}" as personList \u2014 there is no placeholder home for it in the document and no input. A list of people belongs declared as a role with capacity or as a computed text value.`}));continue}A.type==="party"&&(A.key.endsWith("PartyId")||r.push(Re(e,`generatorStamp.inputSchema.${A.key}`,{de:`[governedDocument/partyFieldKey] Party-Feld "${A.key}" endet nicht auf "PartyId" \u2014 aus diesem Suffix wird der Platzhalter-Pr\xE4fix im Dokument abgeleitet (emergencyContactPartyId \u2192 emergency_contact).`,en:`[governedDocument/partyFieldKey] Party field "${A.key}" does not end in "PartyId" \u2014 the placeholder prefix in the document is derived from this suffix (emergencyContactPartyId \u2192 emergency_contact).`})))}r.push(...JL(e,{de:`"${E}"`,en:`"${E}"`}))}}else e.generatorStamp!==void 0&&r.push(Re(e,"generatorStamp",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production '${e.production}', tr\xE4gt aber den Stempel eines Generators \u2014 ohne maschinelle Produktion l\xE4uft keiner.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production '${e.production}' but carries a generator stamp \u2014 without machine production none runs.`}));e.production==="template"?r.push(...Y3(e)):e.templateStamp!==void 0&&r.push(Re(e,"templateStamp",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production '${e.production}', tr\xE4gt aber die Parameter einer Vorlage \u2014 ohne Vorlagen-Produktion wird sie nie gef\xFCllt.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production '${e.production}' but carries a template's parameters \u2014 without template production it is never filled.`}));let k=e.inputs?.[di],g=k===void 0||k.kind==="unset"?void 0:k.kind==="literal"?k.value:k;return g!==void 0&&!ql(g)&&r.push(Re(e,`inputs.${di}`,{de:`[governedDocument/dueInDays] Knoten "${e.id}" setzt responseDueInDays auf ${JSON.stringify(g)} \u2014 erlaubt ist eine ganze Zahl von ${Io} bis ${Oo} Tagen.`,en:`[governedDocument/dueInDays] Node "${e.id}" sets responseDueInDays to ${JSON.stringify(g)} \u2014 a whole number from ${Io} to ${Oo} days is allowed.`})),g===void 0&&Tm(e).some(v=>v.processSource==="responseDueInDays")&&r.push(Re(e,`inputs.${di}`,{de:`[governedDocument/dueInDays] Knoten "${e.id}" druckt die Antwortfrist (processSource 'responseDueInDays'), setzt aber kein responseDueInDays \u2014 das Dokument nennte eine Frist, die es nicht gibt.`,en:`[governedDocument/dueInDays] Node "${e.id}" prints the response deadline (processSource 'responseDueInDays') but sets no responseDueInDays \u2014 the document would name a deadline that does not exist.`})),r},"validate")};var ZL={addPupil:{method:"POST",path:"/api/v1/admissions/AddPrPupilBasic/{schoolid}",kind:"create",body:"PrPupilBasicCreate",required:["forename","surname","genderId"],maxLength:{titleId:4,forename:50,surname:50,middleName:50,preferredForename:50,preferredSurname:50,genderId:4,firstLanguage:4}},addAdmissionDetails:{method:"POST",path:"/api/v1/admissions/AddAdmissionDetails/{schoolid}/{pupilid}",kind:"create",body:"AddPrPupilAdmissionDetails",required:[],maxLength:{boarderStatusId:4,ageAdjust:4,entryYear:4,entryTerm:4,entryYearGroup:4,currentSchoolId:20,enquirySource:4,currentAdmissionStageId:25}},addNationality:{method:"POST",path:"/api/v1/admissions/AddNationlityInfo/{schoolid}/{pupilid}",kind:"create",body:"NationalityInfoCreate",required:["nationalityId"],maxLength:{nationalityId:4,countryOfBirth:4}},addVisa:{method:"POST",path:"/api/v1/admissions/AddVisaInfo/{schoolid}/{pupilid}",kind:"create",body:"CreateVisaInfo",required:[],maxLength:{placeOfBirth:50,passportCountry:4,passportNumber:50,residenceVisaNumber:50,healthCardNumber:50}},addMedical:{method:"POST",path:"/api/v1/admissions/AddMedicalInfo/{schoolid}/{pupilid}",kind:"create",body:"MedicalInfoCreate",required:[],maxLength:{}},addContact:{method:"POST",path:"/api/v1/admissions/AddContactBasicInfo/{schoolid}/{pupilid}",kind:"create",body:"AddContactBasicInfo",required:["titleId","firstName","lastName","genderId"],maxLength:{relationshipId:4,titleId:4,firstName:50,middleName:50,lastName:50,contactName:200,greeting:200,languageId:4,secondLanguageId:4,genderId:4,professionId:4,companyName:50,jobTitle:50}},linkExistingContact:{method:"POST",path:"/api/v1/admissions/LinkExistingContact/{schoolid}/{pupilid}/{contactid}",kind:"create",body:"LinkContact",required:["relationshipId"],maxLength:{relationshipId:4}},addContactAddress:{method:"POST",path:"/api/v1/admissions/AddContactAddressNew/{schoolid}/{contactid}/{addressformatid}",kind:"create",body:"AddAddressVM",required:["countryId"],maxLength:{addressTypeId:4,countryId:4,addressLine1:100,addressLine2:100,addressLine3:100,addressLine4:100,addressLine5:100,addressLine6:100,lookup1:4,lookup2:4,lookup3:4,lookup4:4,lookup5:4}},addContactEmail:{method:"POST",path:"/api/v1/admissions/AddContactEmail/{schoolid}/{contactid}",kind:"create",body:"AddEmailAddress",required:["emailTypeId","email"],maxLength:{emailTypeId:4,email:254}},addContactTelephone:{method:"POST",path:"/api/v1/admissions/AddContactTelephone/{schoolid}/{contactid}",kind:"create",body:"AddTelephoneNumber",required:["typeId","number"],maxLength:{typeId:4}},linkAddressToPupil:{method:"PUT",path:"/api/v1/admissions/LinkAddressToPupil/{schoolId}/{pupilId}/{addressId}",kind:"update",required:[],maxLength:{}},updatePupilAif:{method:"POST",path:"/api/v1/additionalinformation/UpdatePupilAIF/{schoolid}/{pupilid}",kind:"update",body:"AifFieldValueVM",required:[],maxLength:{}},updateContactAif:{method:"POST",path:"/api/v1/additionalinformation/UpdateContactAIF/{schoolid}/{contactid}",kind:"update",body:"AifFieldValueVM",required:[],maxLength:{}},listPupils:{method:"GET",path:"/api/v1/admissions/GetPrPupilBasicInfo/{schoolid}",kind:"read",required:[],maxLength:{}},getPupil:{method:"GET",path:"/api/v1/admissions/GetPrPupilBasicInfoById/{schoolid}/{pupilid}",kind:"read",required:[],maxLength:{}},listContactsOfPupil:{method:"GET",path:"/api/v1/admissions/GetContactBasicInfoByPupilId/{schoolid}/{pupilid}",kind:"read",required:[],maxLength:{}},getContact:{method:"GET",path:"/api/v1/admissions/GetContactByContactId/{schoolid}/{contactid}",kind:"read",required:[],maxLength:{}}};function qt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(qt,"isRecord");var _v=["field","join","literal","address","payment","contract"],Q3=new Set(["text","date","datetime","bool","aifBool","money","moneyText"]),Z3=new Set(["street","streetAndNumber","hausnr","plz","ort","land","full"]);function tr(e){return typeof e=="string"&&e.trim().length>0}s(tr,"nonEmptyString");function $m(e,n,t,r,i="value"){if(!qt(e)||!qt(e.from)){r.push({path:n,code:"mappingShape",message:{de:`${n}: eine Zuordnung braucht \`from\`.`,en:`${n}: a mapping needs \`from\`.`}});return}let o=e.from,a=_v.filter(c=>c in o);if(a.length!==1){r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from\` nennt genau eine Quelle (${_v.join(" | ")}).`,en:`${n}: \`from\` names exactly one source (${_v.join(" | ")}).`}});return}let[l]=a;l==="field"&&!tr(o.field)&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.field\` ist leer.`,en:`${n}: \`from.field\` is empty.`}}),l==="join"&&!(Array.isArray(o.join)&&o.join.length>=2&&o.join.every(tr))&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.join\` nennt mindestens zwei Formularfelder.`,en:`${n}: \`from.join\` names at least two form fields.`}}),e.whenEmpty!==void 0&&(i==="condition"?r.push({path:n,code:"mappingShape",message:{de:`${n}: \`whenEmpty\` gilt nicht f\xFCr eine Bedingung (\`unless\`, \`linkAddressToPupilIf\`).`,en:`${n}: \`whenEmpty\` does not apply to a condition (\`unless\`, \`linkAddressToPupilIf\`).`}}):l!=="field"&&l!=="join"?r.push({path:n,code:"mappingShape",message:{de:`${n}: \`whenEmpty\` gilt nur f\xFCr eine Formularantwort (\`field\`, \`join\`).`,en:`${n}: \`whenEmpty\` applies only to a form answer (\`field\`, \`join\`).`}}):typeof e.whenEmpty=="boolean"||Number.isFinite(e.whenEmpty)||tr(e.whenEmpty)||r.push({path:n,code:"mappingShape",message:{de:`${n}: \`whenEmpty\` ist ein Engage-Wert (Text, Zahl oder ja/nein).`,en:`${n}: \`whenEmpty\` is an Engage value (text, number or yes/no).`}})),l==="address"&&!(we(o.address)&&o.address.scope==="env"&&Wt(o.address.key))&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.address\` ist eine Umgebungsvariable (\`{ scope: 'env', key: 'stage.key' }\`).`,en:`${n}: \`from.address\` is an environment value (\`{ scope: 'env', key: 'stage.key' }\`).`}}),l==="payment"&&o.payment!=="amount"&&o.payment!=="settledAt"&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.payment\` ist amount oder settledAt.`,en:`${n}: \`from.payment\` is amount or settledAt.`}}),l==="contract"&&!["startDate","signedAt","createdAt"].includes(String(o.contract))&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.contract\` ist startDate, signedAt oder createdAt.`,en:`${n}: \`from.contract\` is startDate, signedAt or createdAt.`}}),l==="literal"&&!["string","number","boolean"].includes(typeof o.literal)&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.literal\` ist Text, Zahl oder ja/nein.`,en:`${n}: \`from.literal\` is text, a number or yes/no.`}}),e.format!==void 0&&!Q3.has(String(e.format))&&r.push({path:n,code:"mappingShape",message:{de:`${n}: unbekanntes Format \u201E${String(e.format)}".`,en:`${n}: unknown format "${String(e.format)}".`}}),e.lookup!==void 0&&!(tr(e.lookup)&&qt(t[e.lookup]))&&r.push({path:n,code:"unknownLookup",message:{de:`${n}: die Lookup-Tabelle \u201E${String(e.lookup)}" fehlt in \`lookups\`.`,en:`${n}: the lookup table "${String(e.lookup)}" is missing from \`lookups\`.`}});let d=e.pick;d!==void 0&&(d==="firstWord"||d==="restWords"||d==="year"||qt(d)&&Number.isInteger(d.index)&&Number(d.index)>=0||qt(d)&&Z3.has(String(d.address))||r.push({path:n,code:"mappingShape",message:{de:`${n}: unbekannte Auswahl \`pick\`.`,en:`${n}: unknown selection \`pick\`.`}}))}s($m,"checkMapping");function Gi(e,n,t,r,i){if(!qt(e)){i.push({path:n,code:"bodyShape",message:{de:`${n}: erwartet ein Objekt Feld \u2192 Zuordnung.`,en:`${n}: expects an object field \u2192 mapping.`}});return}let o=ZL[t];for(let a of o.required)a in e||i.push({path:`${n}.${a}`,code:"missingRequired",message:{de:`${n}: Engage verlangt \u201E${a}" (${o.body}) \u2014 es fehlt eine Zuordnung.`,en:`${n}: Engage requires "${a}" (${o.body}) \u2014 a mapping is missing.`}});for(let[a,l]of Object.entries(e))$m(l,`${n}.${a}`,r,i)}s(Gi,"checkBody");function XL(e,n,t,r){if(e===void 0)return;if(!Array.isArray(e)){r.push({path:n,code:"bodyShape",message:{de:`${n}: erwartet eine Liste.`,en:`${n}: expects a list.`}});return}let i=new Set;e.forEach((o,a)=>{let l=`${n}[${a}]`;if(!qt(o)||!tr(o.fieldId)){r.push({path:l,code:"aifShape",message:{de:`${l}: \`fieldId\` fehlt.`,en:`${l}: \`fieldId\` is missing.`}});return}i.has(o.fieldId)&&r.push({path:l,code:"aifDuplicate",message:{de:`${l}: \u201E${o.fieldId}" doppelt.`,en:`${l}: "${o.fieldId}" appears twice.`}}),i.add(o.fieldId),$m(o.value,`${l}.value`,t,r),o.unless!==void 0&&$m(o.unless,`${l}.unless`,t,r,"condition")})}s(XL,"checkAif");function Cv(e){let n=[];if(!qt(e))return[{path:"engage",code:"missing",message:{de:"Die Engage-Zuordnung `engage` fehlt.",en:"The Engage mapping `engage` is missing."}}];let t=qt(e.lookups)?e.lookups:{};qt(e.lookups)||n.push({path:"engage.lookups",code:"bodyShape",message:{de:"`engage.lookups` fehlt (Tabellen Name \u2192 Plexus-Wert \u2192 Engage-Id).",en:"`engage.lookups` is missing (tables name \u2192 Plexus value \u2192 Engage id)."}});for(let[r,i]of Object.entries(t))(!qt(i)||!Object.values(i).every(tr))&&n.push({path:`engage.lookups.${r}`,code:"lookupShape",message:{de:`Lookup \u201E${r}": jede Engage-Id ist ein nicht leerer Text.`,en:`Lookup "${r}": every Engage id is a non-empty text.`}});if(tr(e.addressFormatId)||n.push({path:"engage.addressFormatId",code:"missing",message:{de:"`engage.addressFormatId` fehlt (GetAddressMappingInfo).",en:"`engage.addressFormatId` is missing (GetAddressMappingInfo)."}}),Gi(e.pupil,"engage.pupil","addPupil",t,n),Gi(e.admission,"engage.admission","addAdmissionDetails",t,n),e.nationality!==void 0&&Gi(e.nationality,"engage.nationality","addNationality",t,n),e.visa!==void 0&&Gi(e.visa,"engage.visa","addVisa",t,n),e.medical!==void 0&&Gi(e.medical,"engage.medical","addMedical",t,n),XL(e.pupilAif,"engage.pupilAif",t,n),!Array.isArray(e.contacts))n.push({path:"engage.contacts",code:"bodyShape",message:{de:"`engage.contacts` fehlt (Liste der Kontakte).",en:"`engage.contacts` is missing (list of contacts)."}});else{let r=new Set;e.contacts.forEach((i,o)=>{let a=`engage.contacts[${o}]`;if(!qt(i)||!tr(i.key)||!tr(i.presentIf)){n.push({path:a,code:"contactShape",message:{de:`${a}: \`key\` und \`presentIf\` fehlen.`,en:`${a}: \`key\` and \`presentIf\` are missing.`}});return}r.has(i.key)&&n.push({path:a,code:"contactDuplicate",message:{de:`${a}: Kontakt \u201E${i.key}" doppelt.`,en:`${a}: contact "${i.key}" appears twice.`}}),r.add(i.key),Gi(i.basic,`${a}.basic`,"addContact",t,n),i.address!==void 0&&Gi(i.address,`${a}.address`,"addContactAddress",t,n);for(let[l,d]of[["emails","addContactEmail"],["telephones","addContactTelephone"]]){let c=i[l];if(c!==void 0){if(!Array.isArray(c)){n.push({path:`${a}.${l}`,code:"bodyShape",message:{de:`${a}.${l}: erwartet eine Liste.`,en:`${a}.${l}: expects a list.`}});continue}c.forEach((u,p)=>Gi(u,`${a}.${l}[${p}]`,d,t,n))}}XL(i.aif,`${a}.aif`,t,n),i.linkAddressToPupilIf!==void 0&&$m(i.linkAddressToPupilIf,`${a}.linkAddressToPupilIf`,t,n,"condition")})}if(e.siblingsAttending!==void 0){let r=e.siblingsAttending;(!qt(r)||!tr(r.repeated)||!tr(r.field)||!tr(r.equals))&&n.push({path:"engage.siblingsAttending",code:"bodyShape",message:{de:"`engage.siblingsAttending` braucht repeated, field und equals.",en:"`engage.siblingsAttending` needs repeated, field and equals."}})}return n}s(Cv,"engagePushConfigIssues");function*Dv(e){let n=[e.pupil,e.admission,e.nationality,e.visa,e.medical];for(let t of n)for(let r of Object.values(t??{}))yield{mapping:r};for(let t of e.pupilAif??[])yield{mapping:t.value},t.unless!==void 0&&(yield{mapping:t.unless});for(let t of e.contacts){let r=[t.basic,t.address,...t.emails??[],...t.telephones??[]];for(let i of r)for(let o of Object.values(i??{}))yield{mapping:o,contactKey:t.key};for(let i of t.aif??[])yield{mapping:i.value,contactKey:t.key},i.unless!==void 0&&(yield{mapping:i.unless,contactKey:t.key});t.linkAddressToPupilIf!==void 0&&(yield{mapping:t.linkAddressToPupilIf,contactKey:t.key})}}s(Dv,"mappingsOf");function e0(e){let n=new Set(e.contacts.map(t=>t.presentIf));for(let{mapping:t,contactKey:r}of Dv(e))for(let i of X3(t.from))n.add(e5(i,r));return[...n]}s(e0,"configFieldKeys");function X3(e){return"field"in e?[e.field]:"join"in e?e.join:[]}s(X3,"formFieldsOf");function e5(e,n){return e.startsWith(".")?(n===void 0&&F(`[engagePush] relative field "${e}" outside a contact`),`${n}${e}`):e}s(e5,"resolveFieldKey");function n0(e,n){for(let{mapping:t}of Dv(e))if(n in t.from)return!0;return!1}s(n0,"configReadsSource");function t0(e){let n=new Set;for(let{mapping:t}of Dv(e))"address"in t.from&&n.add(t.from.address.key);return[...n]}s(t0,"configEnvLeaves");var r0="done",i0=["sandbox","production"];var Rm="engagePush",UNe=660*1e3;function zi(e,n,t,r="error"){return{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${n}`,reason:t,severity:r}}s(zi,"issue");function Fv(e,n){let t=e.inputs?.[n];return t?.kind==="literal"?t.value:void 0}s(Fv,"literal");function o0(e){return Cv(e.engage).length===0?e.engage:null}s(o0,"validConfig");function n5(e,n){let t=new Map(e.nodes.map(a=>[a.id,a])),r=e.nodes.filter(a=>a.type==="eventTrigger"),i=new Set,o=r.map(a=>a.id);for(;o.length>0;){let a=o.pop();if(a===n||i.has(a))continue;i.add(a);let l=t.get(a);if(l!==void 0){if(l.type==="end"){let d=l.inputs?.applicationOutcome;if(d?.kind==="literal"&&d.value==="approved")return!0;continue}for(let d of Object.values(l.next??{})){let c=d?.to;typeof c=="string"&&o.push(c)}}}return!1}s(n5,"bypassingPath");var s0={role:"system-action",effect:"side-effect",outcomes:[{id:r0,label:{de:"Angesto\xDFen",en:"Started"}}],envReads:s(e=>{let n=o0(e);return n===null?[]:t0(n)},"envReads"),inputs:s(()=>[{id:"target",label:{de:"Ziel-Engage",en:"Target Engage"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:[{value:"sandbox",label:{de:"Sandbox",en:"Sandbox"}},{value:"production",label:{de:"Produktion",en:"Production"}}]},{id:"contractFields",label:{de:"Vertragsfelder F01\u2013F25",en:"Contract fields F01\u2013F25"},type:"enum",required:!1,inspector:"literal-only",optionSource:"declared",enumOptions:[{value:"off",label:{de:"Nicht \xFCbertragen (Bedeutung offen)",en:"Do not transfer (meaning open)"}},{value:"on",label:{de:"\xDCbertragen",en:"Transfer"}}]}],"inputs"),validate:s((e,n,t)=>{let r=e.label?.de??e.id,i=e.label?.en||e.id,o=[],a=Fv(e,"target");i0.includes(a)||o.push(zi(e,"inputs.target",{de:`[engagePush/invalidTarget] \u201E${r}": das Ziel ist sandbox oder production.`,en:`[engagePush/invalidTarget] "${i}": the target is sandbox or production.`}));let l=Fv(e,"contractFields");l!==void 0&&l!=="off"&&l!=="on"&&o.push(zi(e,"inputs.contractFields",{de:`[engagePush/contractFields] \u201E${r}": Vertragsfelder sind off oder on.`,en:`[engagePush/contractFields] "${i}": contract fields are off or on.`}));let d=e.assign?.[Rm];(typeof d!="string"||d.length===0)&&o.push(zi(e,"assign",{de:`[engagePush/assign] \u201E${r}": wer eine stehen gebliebene \xDCbertragung pr\xFCft, fehlt \u2014 \`assign.${Rm}\` nennt das Team.`,en:`[engagePush/assign] "${i}": nobody is set to check a stalled transfer \u2014 \`assign.${Rm}\` names the team.`}));for(let g of Cv(e.engage))o.push(zi(e,g.path,{de:`[engagePush/config] \u201E${r}": ${g.message.de}`,en:`[engagePush/config] "${i}": ${g.message.en}`}));let c=n.nodes.filter(g=>g.id!==e.id&&g.type==="engagePush"&&Fv(g,"target")===a);c.length>0&&o.push(zi(e,"inputs.target",{de:`[engagePush/twice] \u201E${r}": ${c.map(g=>`"${g.id}"`).join(", ")} \xFCbertr\xE4gt schon an dasselbe Ziel.`,en:`[engagePush/twice] "${i}": ${c.map(g=>`"${g.id}"`).join(", ")} already transfers to the same target.`})),n5(n,e.id)&&o.push(zi(e,"next",{de:`[engagePush/bypassed] \u201E${r}": ein Weg erreicht ein \u201Eangenommen"-Ende, ohne durch die Engage-\xDCbertragung zu laufen \u2014 was dort angenommen wird, k\xE4me nie in Engage an.`,en:`[engagePush/bypassed] "${i}": a path reaches an "accepted" end without passing through the Engage transfer \u2014 what is accepted there would never reach Engage.`}));let u=o0(e),p=e;for(let[g,v,E,A]of[["contract","contract","Vertrag","Contract"],["payment","payment","Zahlung","Payment"]])u===null||!n0(u,g)||p[v]!==void 0||o.push(zi(e,v,{de:Cs("address/missing",{where:`\u201E${r}\u201C \u203A ${E}`},"de"),en:Cs("address/missing",{where:`"${i}" \u203A ${A}`},"en")}));let m=p.form,y=we(m)&&m.scope==="node"?m.owner:void 0,k=y===void 0?void 0:t?.readinessFormFieldsByFormNode?.get(y);if(u!==null&&k!==void 0){let g=new Set(k.keys()),v=e0(u).filter(E=>!g.has(E)&&!/\[\d+\]\./.test(E));if(v.length>0){let E=n.nodes.find(A=>A.id===y);o.push(zi(e,"engage",{de:`[engagePush/unmappedField] \u201E${r}": diese Felder kennt das Formular \u201E${E?.label?.de??y}" nicht \u2014 sie werden nicht \xFCbertragen: ${v.join(", ")}.`,en:`[engagePush/unmappedField] "${i}": the form "${E?.label?.en||y}" does not know these fields \u2014 they are not transferred: ${v.join(", ")}.`},"warning"))}}return o},"validate")};var Vo={join:KF,end:JO,roleAssign:BF,eventTrigger:VF,waitlist:oL,completenessCheck:pL,form:JF,setFlag:QF,if:ZF,decision:Bo,review:hL,collectPayment:vL,governedDocument:QL,countersign:b_,engagePush:s0};HI(Vo);function a0(e,n){let t=e;if(t==null||!Array.isArray(t.nodes))throw new Error(`offer plan: the ${n} carries no workflow graph with nodes`);return e}s(a0,"graphOf");function l0(e){let n=new Map;for(let t of e.nodes)for(let r of Dr(e,t))n.set(se(r.address),r.nodeId);return n}s(l0,"producedOf");function d0(e){let n=new Map;for(let t of e.nodes)n.set(t.id,new Set(bo(e,t).map(r=>se(r.address))));return n}s(d0,"readsOf");function c0(e,n){let t=a0(e,"bundle"),r=a0(n.graph,"live head"),i=l0(t),o=l0(r),a={added:[],removed:[],moved:[]};for(let[u,p]of i){let m=o.get(u);m===void 0?a.added.push({address:u,nodeId:p}):m!==p&&a.moved.push({address:u,from:m,to:p})}for(let[u,p]of o)i.has(u)||a.removed.push({address:u,nodeId:p});let l=d0(t),d=d0(r),c=[];for(let u of new Set([...l.keys(),...d.keys()])){let p=l.get(u)??new Set,m=d.get(u)??new Set,y=[...p].filter(g=>!m.has(g)),k=[...m].filter(g=>!p.has(g));(y.length>0||k.length>0)&&c.push({nodeId:u,added:y,removed:k})}return{headRevision:n.revision,pinnedApplications:n.pinnedApplications,produced:a,reads:c}}s(c0,"planAddresses");function u0(e){let n=[...e.produced.moved.map(i=>({icon:"~",target:`address:${i.address}`,status:`Knoten ${i.from} \u2192 ${i.to}`})),...e.produced.added.map(i=>({icon:"+",target:`address:${i.address}`,status:`neu (${i.nodeId})`})),...e.produced.removed.map(i=>({icon:"-",target:`address:${i.address}`,status:`entfernt (${i.nodeId})`})),...e.reads.map(i=>({icon:"~",target:`reads:${i.nodeId}`,status:[i.added.length>0?`+${i.added.join(", ")}`:"",i.removed.length>0?`\u2212${i.removed.join(", ")}`:""].filter(Boolean).join(" ")}))];if(n.length===0)return[];let{real:t,test:r}=e.pinnedApplications;return n.push({icon:"!",target:"pinned",status:`${t+r} Anmeldungen (${t} echt, ${r} Test) auf Fassung ${e.headRevision} bleiben auf ihrer Version \u2014 Umpinnen nur per Migration mit Abbildung`}),n}s(u0,"addressPlanRows");function f0(e,n){return n==null?!0:Pe(e)!==Pe(n)}s(f0,"changed");async function p0(e,n,t){if(n.index.module!==ev.name)throw new Error(`offer: unknown module "${n.index.module}"`);return Z_(e,n,t,{afterManifestPublish:s(async()=>{if(n.index.links?.unitKey||n.index.program)return ev.scaffold(e,n.index.slugs.manifest,n.index,{dryRun:t.dryRun??!1})},"afterManifestPublish")})}s(p0,"applyOffer");async function m0(e,n,t,r="published"){let i=await e.query(x.setup.offerBundle.exportOfferBundle,{client:n,offerKey:t,generation:r});return{bundle:i.bundle,generation:i.generation,revision:i.revision}}s(m0,"exportOffer");async function Lv(e,n){let{index:t}=n,i=(await e.query(x.workflow.listManifests,{client:t.tenant})).find(y=>y.offerKey===t.slugs.manifest),o="create";i&&(o="same");let a={};for(let[y,k]of Object.entries(n.smartforms??{})){let g=i?await e.query(x.forms.getSmartFormBySlug,{client:t.tenant,offerVersionId:i.offerVersionId,slug:y}):null;a[y]=g?.def?f0(k,{label:g.def.label,...g.def.definition})?"change":"same":"create"}let l="absent",d=null;if(n.workflow!==void 0){if(l="create",i?.workflowDefinitionId){let y=await e.query(x.workflow.getWorkflowDef,{workflowDefinitionId:i.workflowDefinitionId}),k=y?.publishedVersion??y?.draftVersion;l=f0(k&&{graph:bs(n.workflow.graph),progressLayout:n.workflow.progressLayout??k.progressLayout,progressWiring:n.workflow.progressWiring??k.progressWiring},k&&{graph:bs(k.graph),progressLayout:k.progressLayout,progressWiring:k.progressWiring})?"change":"same"}if(i){let y=await e.query(x.workflow.getOfferHeadPins,{client:t.tenant,offerKey:t.slugs.manifest});y!==null&&(d=c0(n.workflow.graph,y))}}let c=t.program?.stages,u=c===void 0?[]:i?await Xb(e,t.tenant,t.slugs.manifest,c):cm(null,[],c),p=await hm(e,t.tenant,i?t.slugs.manifest:null,t),m=i?await e.query(x.workflow.getOfferPublishState,{client:t.tenant,offerKey:t.slugs.manifest}):null;return{manifest:o,smartforms:a,workflow:l,addresses:d,stages:u,capacities:p,publishPending:m?.draftDiffersFromExternal??null,draftRevision:m?.draftRevision??null,externalHeadRevision:m?.externalHeadRevision??null}}s(Lv,"diffOffer");function Im(e){if(e.type==="governedDocument"){let n=e.production;return n==="resolver"?"resolver":n==="template"?"template":n==="upload"||n==="none"?"manual":"unauthored"}return null}s(Im,"contractProductionModeOf");function h0(e){return Im(e)==="resolver"}s(h0,"isResolverCarrierNode");function Om(e){return(e.workflow?.graph?.nodes??[]).flatMap(t=>{let r=ni(t);return!h0(t)||r===null?[]:[{node:t,key:r.key,kind:r.kind,...r.revision===void 0?{}:{revision:r.revision}}]})}s(Om,"authoredPins");var g0={type:"address",dataType:"composite"};var y0={type:"boolean",dataType:"boolean"};var w0={type:"consent",dataType:"boolean"};var k0={type:"date",dataType:"date"};var b0={type:"docRef",dataType:"file"};var v0={type:"email",dataType:"text"};var x0={type:"enum",dataType:"option"};var S0={type:"string",dataType:"text"};var A0={type:"tel",dataType:"text"};var Pm={address:g0.dataType,boolean:y0.dataType,consent:w0.dataType,date:k0.dataType,docRef:b0.dataType,email:v0.dataType,enum:x0.dataType,string:S0.dataType,tel:A0.dataType};function Mv(e){return{type:e.type,multiple:e.multiple===!0,enumListKey:e.enumListKey,enumOptions:e.enumOptions}}s(Mv,"shapeOf");function E0(e){let n=new Map,t=[],r=s(o=>{o.fields.forEach(a=>n.set(a.key,Mv(a))),o.groups?.forEach(a=>a.fields.forEach(l=>n.set(l.key,Mv(l)))),o.repeated?.forEach(a=>t.push({key:a.key,itemTemplate:a.itemTemplate,effects:a.effects??[]})),o.subsections?.forEach(r)},"visit");e.sections.forEach(r);let i=[{pathPrefix:"",effects:e.effects??[],shapes:n}];for(let o of t){let a=new Map(n);o.itemTemplate.forEach(l=>a.set(`$item.${l.key}`,Mv(l))),i.push({pathPrefix:`repeated '${o.key}'.`,effects:o.effects,shapes:a})}return i}s(E0,"fieldMapScopes");function t5(e){let n=new Set,t=s(r=>{r.computed?.forEach(i=>n.add(i.key)),r.subsections?.forEach(t)},"visit");return e.sections.forEach(t),n}s(t5,"computedKeysOf");function T0(e){let n=[],t=t5(e);for(let r of E0(e))r.effects.forEach((i,o)=>{if(i.kind!=="fieldMap")return;let a=new Map;i.mappings.forEach((l,d)=>{let c=`${r.pathPrefix}effects[${o}].mappings[${d}]`;t.has(l.from)&&n.push({severity:"error",path:`${c}.from`,code:"fieldmap.computed-source",message:`Effect '${i.id}' fieldMap '${l.from}' \u2192 '${l.to}': '${l.from}' is a computed field. Its value is derived, never stored, and would never reach the party.`});let u=a.get(l.to);u!==void 0&&u!==l.from?n.push({severity:"error",path:`${c}.to`,code:"fieldmap.duplicate-target",message:`Effect '${i.id}' maps both '${u}' and '${l.from}' onto custom field '${l.to}'. One party field holds one value \u2014 the write would keep one and drop the other.`}):a.set(l.to,l.from)})});return n}s(T0,"validateFieldMapSources");function $0(e){let n=[],t=new Set;for(let o of E0(e))for(let a of o.effects)if(a.kind==="fieldMap")for(let l of a.mappings)t.add(l.from);let r=s((o,a)=>{let l=a.some(d=>t.has(d));o.kind==="cf_value"&&!l?n.push({severity:"error",path:`field '${o.key}'`,code:"persist.cf-unmapped",message:`Field '${o.key}' declares kind 'cf_value' but is not the source of any fieldMap mapping. Either wire a fieldMap ('${o.key}' \u2192 a custom-field key) or set kind: 'control'.`}):o.kind==="control"&&l&&n.push({severity:"error",path:`field '${o.key}'`,code:"persist.control-mapped",message:`Field '${o.key}' declares kind 'control' but is used as a fieldMap source, which would persist it. Set kind: 'cf_value', or remove the fieldMap mapping (a control field may still feed OutcomeDef.output.fields).`})},"check"),i=s(o=>{o.fields.forEach(a=>r(a,[a.key])),o.groups?.forEach(a=>a.fields.forEach(l=>r(l,[l.key]))),o.repeated?.forEach(a=>a.itemTemplate.forEach(l=>r(l,[`$item.${l.key}`,l.key]))),o.subsections?.forEach(i)},"visit");return e.sections.forEach(i),n}s($0,"validateFieldPersistence");var r5="$";function i5(e){return typeof e=="string"&&e.startsWith(r5)}s(i5,"isRef");function Nm(e){return e.slice(1)}s(Nm,"stripRef");function*o5(e){switch(e.kind){case"relationship":if(yield e.from,yield e.to,e.meta)for(let n of Object.values(e.meta))yield n;return;case"fieldMap":yield e.target;return;case"shareValue":yield e.from,yield e.to;return;case"person":case"organization":return}}s(o5,"refSlots");function s5(e){let n=new Set;for(let t of o5(e))i5(t)&&n.add(Nm(t));return[...n]}s(s5,"collectRefs");function a5(e){let n=new Set(e.map(o=>o.id)),t=new Map,r=new Map,i=new Map;for(let o of e)i.set(o.id,o),t.set(o.id,[]),r.set(o.id,[]);for(let o of e)for(let a of s5(o))n.has(a)&&(t.get(o.id).push(a),r.get(a).push(o.id));for(let o of e){if(o.kind!=="shareValue")continue;let a=Nm(o.from);for(let l of e)l.id===o.id||!(l.kind==="fieldMap"&&Nm(l.target)===a||l.kind==="shareValue"&&Nm(l.to)===a)||t.get(o.id).includes(l.id)||(t.get(o.id).push(l.id),r.get(l.id).push(o.id))}return{refsOf:t,successors:r,byId:i}}s(a5,"buildAdjacency");function R0(e){let{refsOf:n}=a5(e),r=Xf(e.map(i=>i.id),i=>(n.get(i)??[]).map(o=>({target:o,edge:null})))[0];return r===void 0?{hasCycle:!1}:{hasCycle:!0,cycle:r.cycle}}s(R0,"detectCycle");function I0(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}s(I0,"escapeRegExp");function Wi(e){return new RegExp(`^${I0(e)}\\[(\\d+)\\]\\.(.+)$`)}s(Wi,"repeatedRowKeyPattern");function qv(e,n){let t=Wi(n),r=0;for(let i of Object.keys(e)){let o=i.match(t);if(!o)continue;let a=Number(o[1]);Number.isInteger(a)&&a+1>r&&(r=a+1)}return r}s(qv,"countRepeatedRows");function O0(e,n,t){let r=Wi(n);for(let[i,o]of Object.entries(e)){let a=i.match(r);if(!(!a||Number(a[1])!==t)&&o!=null&&!(typeof o=="string"&&o.trim()==="")&&!(Array.isArray(o)&&o.length===0))return!0}return!1}s(O0,"repeatedRowHasData");function P0(e){return e.endsWith(".count")?e.slice(0,-6):e}s(P0,"readKeyOf");function Kv(e){return{sections:e,fields:[]}}s(Kv,"hiddenSectionsOnly");function N0(e,n,t){for(let r of e.fields)n.add(r.key);for(let r of e.groups??[])for(let i of r.fields)n.add(i.key);for(let r of e.computed??[])n.add(r.key);for(let r of e.repeated??[])t.add(r.key);for(let r of e.subsections??[])N0(r,n,t)}s(N0,"collectKeys");function _0(e){let n=[],t=s(r=>{if(r.visibleTo!==void 0){let i=new Set,o=new Set;N0(r,i,o),n.push({sectionId:r.id,label:r.label,visibleTo:r.visibleTo,fieldKeys:i,repeatedKeys:o,rowKeyPatterns:[...o].map(Wi)});return}for(let i of r.subsections??[])t(i)},"visit");for(let r of e.sections)t(r);return n}s(_0,"restrictedSectionsOf");function C0(e,n){return n.fieldKeys.has(e)||n.repeatedKeys.has(e)?!0:n.rowKeyPatterns.some(t=>t.test(e))}s(C0,"matchesKey");function l5(e,n){return n.find(t=>C0(e,t))??null}s(l5,"hiddenSectionOfKey");function d5(e,n){for(let t=e;;){if(C0(t,n))return!0;let r=t.lastIndexOf(".");if(r===-1)return!1;t=t.slice(0,r)}}s(d5,"fieldOwnsKey");function c5(e,n){return n.find(t=>d5(e,t))??null}s(c5,"restrictedFieldOfKey");function u5(e,n){let t=l5(e,n.sections);if(t!==null)return{kind:"section",section:t};let r=c5(e,n.fields);return r===null?null:{kind:"field",field:r}}s(u5,"hiddenOwnerOfKey");function _m(e,n){return u5(e,n)!==null}s(_m,"isKeyHidden");function f5(e,n,t,r,i){let o=[];r&&o.push({severity:"error",path:t,code:"section.visibleTo-nested",message:{de:`Abschnitt '${e}' liegt in einem Abschnitt mit eingeschr\xE4nkter Sichtbarkeit (visibleTo) und darf selbst keine tragen.`,en:`Section '${e}' sits inside a section with restricted visibility (visibleTo) and may not carry one itself.`}});let a=s(l=>typeof l!="string"||l.trim()==="","isBlank");if((n.length===0||n.some(a)||new Set(n).size!==n.length)&&o.push({severity:"error",path:t,code:"section.visibleTo-invalid",message:{de:`Abschnitt '${e}': visibleTo braucht mindestens ein Team, ohne leere oder doppelte Eintr\xE4ge.`,en:`Section '${e}': visibleTo needs at least one team, with no blank or repeated entries.`}}),i===void 0)return o;for(let l of n)a(l)||i.has(l)||o.push({severity:"error",path:t,code:"section.visibleTo-unknown",message:{de:`Abschnitt '${e}': '${l}' ist weder ein Team noch eine Rechtegruppe dieser Schule.`,en:`Section '${e}': '${l}' is neither a team nor a permission group of this school.`}});return o}s(f5,"visibleToListIssues");function D0(e,n,t){let r=[],i=s((c,u,p)=>{let m=c.visibleTo;m!==void 0&&r.push(...f5(c.id,m,`${u}.visibleTo`,p,t));let y=p||m!==void 0;if(y){let k=[...c.fields,...(c.groups??[]).flatMap(g=>g.fields),...(c.repeated??[]).flatMap(g=>g.itemTemplate)];for(let g of k)g.kind==="cf_value"&&r.push({severity:"error",path:`${u}.fields`,code:"section.visibleTo-party",message:{de:`Feld '${g.key}' wird in die Personendaten \xFCbernommen und kann deshalb nicht in einem Abschnitt mit eingeschr\xE4nkter Sichtbarkeit (visibleTo) liegen.`,en:`Field '${g.key}' is carried into the person record and therefore cannot sit in a section with restricted visibility (visibleTo).`}})}(c.subsections??[]).forEach((k,g)=>i(k,`${u}.subsections[${g}]`,y))},"visitRaw");e.sections.forEach((c,u)=>i(c,`sections[${u}]`,!1));let o=_0(e);if(o.length===0)return r;let a=s((c,u,p)=>{if(c===void 0)return;let m=Kv(p);for(let y of xn(c)){let k=P0(y);(_m(y,m)||_m(k,m))&&r.push({severity:"error",path:u,code:"section.visibleTo-read-outside",message:{de:`${u} liest '${y}' aus einem Abschnitt mit eingeschr\xE4nkter Sichtbarkeit (visibleTo) \u2014 wer den Abschnitt nicht sieht, bek\xE4me hier ein anderes Ergebnis.`,en:`${u} reads '${y}' from a section with restricted visibility (visibleTo) \u2014 whoever cannot see the section would get a different result here.`}})}},"checkAst"),l=s((c,u,p)=>{a(c.visibleIf,`${u}.visibleIf`,p),a(c.requiredIf,`${u}.requiredIf`,p),a(c.disabledIf,`${u}.disabledIf`,p),a(c.defaultValue,`${u}.defaultValue`,p),c.sameAs!==void 0&&_m(c.sameAs.source,Kv(p))&&r.push({severity:"error",path:`${u}.sameAs`,code:"section.visibleTo-read-outside",message:{de:`${u} \xFCbernimmt '${c.sameAs.source}' aus einem Abschnitt mit eingeschr\xE4nkter Sichtbarkeit (visibleTo).`,en:`${u} copies '${c.sameAs.source}' from a section with restricted visibility (visibleTo).`}})},"checkField"),d=s((c,u,p)=>{let m=c.visibleTo!==void 0?c.id:p,y=o.filter(k=>k.sectionId!==m);a(c.visibleIf,`${u}.visibleIf`,c.visibleTo!==void 0?o:y),c.fields.forEach((k,g)=>l(k,`${u}.fields[${g}]`,y)),c.groups?.forEach((k,g)=>{a(k.visibleIf,`${u}.groups[${g}].visibleIf`,y),k.fields.forEach((v,E)=>l(v,`${u}.groups[${g}].fields[${E}]`,y))}),c.repeated?.forEach((k,g)=>{a(k.itemVisibleIf,`${u}.repeated[${g}].itemVisibleIf`,y),k.itemTemplate.forEach((v,E)=>l(v,`${u}.repeated[${g}].itemTemplate[${E}]`,y))}),c.computed?.forEach((k,g)=>a(k.expression,`${u}.computed[${g}]`,y)),c.subsections?.forEach((k,g)=>d(k,`${u}.subsections[${g}]`,m))},"visitCompiled");return n.sections.forEach((c,u)=>d(c,`sections[${u}]`,null)),r}s(D0,"sectionVisibilityIssues");var Ur="#";var F0=s(e=>{let n=wk.find(t=>t.systemColumn===e);return n===void 0&&F(`[personName] no system field backs ${e}`),n.key},"keyOfColumn"),vr={firstName:F0("persons.firstName"),lastName:F0("persons.lastName")};function L0(e,n){let t={firstName:[],lastName:[]},r=`$${e}`;for(let i of n)if(!(i.kind!=="fieldMap"||i.target!==r))for(let{from:o,to:a}of i.mappings??[])a===vr.firstName?t.firstName.push(o):a===vr.lastName&&t.lastName.push(o);return t}s(L0,"personNameKeys");function M0(e){return[...e.firstName,...e.lastName]}s(M0,"personNameKeyList");function q0(e){return e.firstName.length>0||e.lastName.length>0}s(q0,"hasPersonName");function wa(e,n=[],t){let r=[];return e.forEach((i,o)=>{let a=[...n,o];r.push({section:i,path:a,parentId:t});for(let l of wa(i.subsections??[],a,i.id))r.push(l)}),r}s(wa,"walkSections");function p5(e,n){for(let t of e.fields)if(t.key===n)return t;for(let t of e.groups??[])for(let r of t.fields)if(r.key===n)return r;for(let t of e.repeated??[])for(let r of t.itemTemplate)if(r.key===n)return r;return null}s(p5,"findFieldInSection");function K0(e,n){for(let t of wa(e.sections)){let r=p5(t.section,n);if(r)return{section:t.section,field:r}}return null}s(K0,"findField");var m5=["Baby","BookOpen","BriefcaseBusiness","Building2","FileText","GraduationCap","HeartHandshake","Scale","UserCheck","UserRound","Users","UsersRound"],h5=["blue","rose","amber","violet","teal","emerald","slate"];function j0(e){return m5.includes(e)}s(j0,"isBucketIconName");function B0(e){return h5.includes(e)}s(B0,"isBucketColorName");var g5="__clear__";function V0(e){return e===""?"empty":e===g5?"reserved":null}s(V0,"selectOptionValueDefect");var jv=tD.docRef.allowedMime;function H0(e,n={}){let t=Zs(e).compiled,r=[],i=new Set,o=new Map,a=new Set,l=new Set,d=new Set,c=new Map,u=new Map;function p(O,N){if(i.has(O))return;i.add(O);let K=o.get(O.id);K&&K!==O?r.push({severity:"error",path:`sections[${N.join(".")}]`,code:"duplicate.section-id",message:{de:`Abschnitts-ID '${O.id}' ist mehrfach deklariert.`,en:`Section id '${O.id}' is declared more than once.`}}):o.set(O.id,O);let C=`sections[${N.join(".")}]`;O.fields.forEach((G,ae)=>{ka(a,G.key,`${C}.fields[${ae}]`,"duplicate.field-key",r),l.add(G.key),u.set(G.key,G),c.set(G.key,Vv(G)),G.externalFlag&&(G.type!=="boolean"&&r.push({severity:"error",path:`${C}.fields[${ae}]`,code:"flag.not-boolean",message:{de:`Externes Flag '${G.key}' muss den Typ 'boolean' haben (ist '${G.type}').`,en:`External flag '${G.key}' must be type 'boolean' (got '${G.type}').`}}),G.reviewRequired!==void 0&&r.push({severity:"error",path:`${C}.fields[${ae}]`,code:"review.on-flag",message:{de:`Externes Flag '${G.key}' ist als pr\xFCfpflichtig markiert \u2014 ein Flag setzt der Prozess, die Familie reicht nichts ein, was jemand pr\xFCfen k\xF6nnte.`,en:`External flag '${G.key}' is marked as requiring review \u2014 the process sets a flag, the family hands in nothing anyone could review.`}}),G.notice!==void 0&&r.push({severity:"error",path:`${C}.fields[${ae}]`,code:"config.notice-on-flag",message:{de:`Externes Flag '${G.key}' tr\xE4gt einen Hinweis (notice) \u2014 ein Flag wird der Familie nie angezeigt, also auch sein Hinweis nicht.`,en:`External flag '${G.key}' carries a notice \u2014 a flag is never shown to the family, so neither is its notice.`}}),G.defaultValue==null&&r.push({severity:"error",path:`${C}.fields[${ae}]`,code:"flag.missing-default",message:{de:`Externes Flag '${G.key}' muss einen defaultValue deklarieren (z. B. "false"), damit es standardm\xE4\xDFig verborgen ist.`,en:`External flag '${G.key}' must declare a defaultValue (e.g. "false") so it is hidden by default.`}})),r.push(...G0(G,`${C}.fields[${ae}]`)),r.push(...U0(G,`${C}.fields[${ae}]`))}),O.groups?.forEach((G,ae)=>{G.fields.forEach((ce,Ce)=>{ka(a,ce.key,`${C}.groups[${ae}].fields[${Ce}]`,"duplicate.field-key",r),l.add(ce.key),u.set(ce.key,ce),c.set(ce.key,Vv(ce)),ce.externalFlag&&r.push({severity:"error",path:`${C}.groups[${ae}].fields[${Ce}]`,code:"flag.invalid-location",message:{de:`Externes Flag '${ce.key}' muss ein direktes Abschnittsfeld sein, kein Gruppenfeld.`,en:`External flag '${ce.key}' must be a direct section field, not a group field.`}}),r.push(...G0(ce,`${C}.groups[${ae}].fields[${Ce}]`)),r.push(...U0(ce,`${C}.groups[${ae}].fields[${Ce}]`))})}),O.repeated?.forEach((G,ae)=>{G.itemTemplate.forEach((ce,Ce)=>{ka(a,ce.key,`${C}.repeated[${ae}].itemTemplate[${Ce}]`,"duplicate.field-key",r),c.set(ce.key,Vv(ce)),ce.externalFlag&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"flag.invalid-location",message:{de:`Externes Flag '${ce.key}' muss ein direktes Abschnittsfeld sein, kein Feld einer Wiederholung.`,en:`External flag '${ce.key}' must be a direct section field, not a repeated item field.`}}),ce.export&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"export.in-repeated",message:{de:`Feld '${ce.key}' deklariert export in einem itemTemplate einer Wiederholung \u2014 ein zusammengesetztes Blatt gilt je Bewerbung, ein Zeilenfeld je Zeile.`,en:`Field '${ce.key}' declares export inside a repeated itemTemplate \u2014 a compound leaf is per-application, a row field is per-row.`}}),ce.sameAs&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"config.sameas-in-repeated",message:{de:`Feld '${ce.key}' deklariert sameAs in einem itemTemplate einer Wiederholung \u2014 nicht unterst\xFCtzt.`,en:`Field '${ce.key}' declares sameAs inside a repeated itemTemplate \u2014 not supported.`}}),ce.reviewRequired!==void 0&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"review.in-repeated",message:{de:`Feld '${ce.key}' ist in einem itemTemplate einer Wiederholung als pr\xFCfpflichtig markiert \u2014 ein Zeilenfeld hat je Zeile einen Wert, kein Feld der Bewerbung, das man einmal abhaken k\xF6nnte.`,en:`Field '${ce.key}' is marked as requiring review inside a repeated itemTemplate \u2014 a row field has one value per row, no field of the application to tick once.`}}),ce.notice!==void 0&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"config.notice-in-repeated",message:{de:`Feld '${ce.key}' tr\xE4gt einen Hinweis (notice) in einem itemTemplate einer Wiederholung \u2014 dort wird er nicht angezeigt. Den Hinweis an den Abschnitt setzen.`,en:`Field '${ce.key}' carries a notice inside a repeated itemTemplate \u2014 it is not shown there. Put the notice on the section.`}}),ce.type==="docRef"&&ce.docRefConstraints?.multiple===!0&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"config.docref-multiple-in-repeated",message:{de:`Feld '${ce.key}' setzt docRefConstraints.multiple in einem itemTemplate einer Wiederholung \u2014 ein Mehrfach-Upload ist nur als Abschnitts- oder Gruppenfeld m\xF6glich.`,en:`Field '${ce.key}' sets docRefConstraints.multiple inside a repeated itemTemplate \u2014 a multi-file upload is supported only as a section or group field.`}})})}),O.computed?.forEach(G=>{d.add(G.key),ka(a,G.key,`${C}.computed[${G.key}]`,"duplicate.field-key",r),G.exportType==="consent"&&r.push({severity:"error",path:`${C}.computed[${G.key}]`,code:"config.consent-computed",message:{de:`Berechnetes Feld '${G.key}' ist als Zustimmung (consent) typisiert \u2014 eine Zustimmung gibt die Person selbst, keine Berechnung. exportType 'boolean' verwenden.`,en:`Computed '${G.key}' is typed as a consent \u2014 a consent is given by the person, never computed. Use exportType 'boolean'.`}}),G.export===!0&&G.exportType===void 0&&r.push({severity:"error",path:`${C}.computed[${G.key}]`,code:"export.computed-untyped",message:{de:`Berechnetes Feld '${G.key}' wird ohne exportType exportiert \u2014 string | number | boolean | date angeben.`,en:`Computed '${G.key}' is exported without an exportType \u2014 declare string | number | boolean | date.`}})}),O.subsections?.forEach((G,ae)=>p(G,[...N,ae]))}s(p,"visitRawSection"),e.sections.forEach((O,N)=>p(O,[N]));let m=new Set;t.effects.forEach((O,N)=>{ka(m,O.id,`effects[${N}]`,"duplicate.effect-id",r)});let y=new Set;t.outcomes.forEach((O,N)=>{ka(y,O.id,`outcomes[${N}]`,"duplicate.outcome-id",r)}),t.outcomes.forEach((O,N)=>{O.output.effectRefs?.forEach((K,C)=>{m.has(K.effect)||r.push({severity:"error",path:`outcomes[${N}].output.effectRefs[${C}]`,code:"ref.unknown-effect",message:{de:`Ergebnis '${O.id}' verweist auf den unbekannten Effekt '${K.effect}'.`,en:`Outcome '${O.id}' references unknown effect '${K.effect}'.`}})})}),t.outcomes.forEach((O,N)=>{O.output.fields?.forEach((K,C)=>{K0(t,K.path)||r.push({severity:"error",path:`outcomes[${N}].output.fields[${C}]`,code:"ref.unknown-field",message:{de:`Ergebnis '${O.id}' verweist auf das unbekannte Feld '${K.path}'.`,en:`Outcome '${O.id}' references unknown field '${K.path}'.`}})})});let k=new Set;for(let O of wa(t.sections))for(let N of O.section.repeated??[])k.add(`${N.key}.count`);for(let O of k)(a.has(O)||d.has(O))&&r.push({severity:"error",path:"sections",code:"duplicate.field-key",message:{de:`'${O}' ist zugleich ein deklarierter Schl\xFCssel und die abgeleitete Zeilenzahl einer Wiederholung \u2014 der abgeleitete Wert w\xFCrde stillschweigend gewinnen.`,en:`'${O}' is both a declared key and the derived row count of a repeated group \u2014 the derived value would silently win.`}});let g={known:new Set([...a,...d,...k]),declaredContext:new Set(e.env??[]),stageKeys:n.stageKeys};r.push(...gN(e)),r.push(...D0(e,t,n.visibleToKeys)),r.push(...QN(e)),r.push(...pN(e,n.stageKeys));for(let O of wa(t.sections)){let N=O.section,K=`sections[${O.path.join(".")}]`;N.visibleIf&&(xr(N.visibleIf,`${K}.visibleIf`,g,!1,r),ba(N.visibleIf,`${K}.visibleIf`,c,r)),N.fields.forEach((C,G)=>Bv(C,`${K}.fields[${G}]`,g,!1,c,r)),N.groups?.forEach((C,G)=>{C.visibleIf&&(xr(C.visibleIf,`${K}.groups[${G}].visibleIf`,g,!1,r),ba(C.visibleIf,`${K}.groups[${G}].visibleIf`,c,r)),C.fields.forEach((ae,ce)=>Bv(ae,`${K}.groups[${G}].fields[${ce}]`,g,!1,c,r))}),N.repeated?.forEach((C,G)=>{C.itemVisibleIf&&(xr(C.itemVisibleIf,`${K}.repeated[${G}].itemVisibleIf`,g,!0,r),ba(C.itemVisibleIf,`${K}.repeated[${G}].itemVisibleIf`,c,r)),C.itemTemplate.forEach((ae,ce)=>Bv(ae,`${K}.repeated[${G}].itemTemplate[${ce}]`,g,!0,c,r)),C.effects?.forEach((ae,ce)=>{ae.when&&xr(ae.when,`${K}.repeated[${G}].effects[${ce}].when`,g,!0,r)})}),N.computed?.forEach((C,G)=>xr(C.expression,`${K}.computed[${G}].expression`,g,!1,r))}t.effects.forEach((O,N)=>{O.when&&xr(O.when,`effects[${N}].when`,g,!1,r)}),t.outcomes.forEach((O,N)=>{xr(O.when,`outcomes[${N}].when`,g,!1,r)});let v=new Set(t.outcomes.map(O=>O.id));function E(O,N){O.requiredFor&&O.requiredFor.forEach((K,C)=>{v.has(K)||r.push({severity:"error",path:`${N}.requiredFor[${C}]`,code:"ref.unknown-required-for-outcome",message:{de:`Feld "${O.key}": requiredFor verweist auf das unbekannte Ergebnis "${K}"`,en:`field "${O.key}": requiredFor references unknown outcome "${K}"`}})})}s(E,"checkRequiredFor");for(let O of wa(t.sections)){let N=O.section,K=`sections[${O.path.join(".")}]`;N.fields.forEach((C,G)=>E(C,`${K}.fields[${G}]`)),N.groups?.forEach((C,G)=>{C.fields.forEach((ae,ce)=>E(ae,`${K}.groups[${G}].fields[${ce}]`))}),N.repeated?.forEach((C,G)=>{C.itemTemplate.forEach((ae,ce)=>E(ae,`${K}.repeated[${G}].itemTemplate[${ce}]`))})}function A(O,N){let K=s((C,G)=>{let ae=(C.type==="docRef"?C.docRefConstraints?.mimeType??[]:[]).filter(Ae=>!jv.includes(Ae));ae.length>0&&r.push({severity:"error",path:G,code:"config.docref-type-outside-ceiling",message:{de:`Feld '${C.key}' erlaubt ${ae.map(Ae=>`'${Ae}'`).join(", ")} \u2014 kein Dokument-Upload akzeptiert diesen Typ (erlaubt: ${jv.join(", ")}).`,en:`Field '${C.key}' allows ${ae.map(Ae=>`'${Ae}'`).join(", ")} \u2014 no document upload accepts that type (allowed: ${jv.join(", ")}).`}});let ce=C.type==="docRef"?C.docRefConstraints?.minFiles:void 0;if(ce!==void 0){let Ae=C.docRefConstraints?.multiple===!0,hn=typeof ce=="number"&&Number.isInteger(ce)&&ce>=2;(!Ae||!hn)&&r.push({severity:"error",path:G,code:"config.docref-min-files",message:Ae?{de:`Feld '${C.key}' setzt docRefConstraints.minFiles auf ${JSON.stringify(ce)} \u2014 erlaubt ist eine ganze Zahl ab 2.`,en:`Field '${C.key}' sets docRefConstraints.minFiles to ${JSON.stringify(ce)} \u2014 it must be a whole number of at least 2.`}:{de:`Feld '${C.key}' setzt docRefConstraints.minFiles ohne docRefConstraints.multiple: true \u2014 eine Mindestanzahl gibt es nur bei einem Mehrfach-Upload.`,en:`Field '${C.key}' sets docRefConstraints.minFiles without docRefConstraints.multiple: true \u2014 a minimum count exists only on a multi-file upload.`}})}C.multiple===!0&&C.type!=="enum"&&r.push({severity:"error",path:G,code:"config.multiple-non-enum",message:{de:`Feld '${C.key}' setzt multiple: true, hat aber den Typ '${C.type}' \u2014 nur 'enum' unterst\xFCtzt Mehrfachauswahl.`+(C.type==="docRef"?" F\xFCr mehrere Dateien docRefConstraints.multiple: true verwenden.":""),en:`Field '${C.key}' sets multiple: true but is type '${C.type}' \u2014 only 'enum' supports multi-select.`+(C.type==="docRef"?" For several files use docRefConstraints.multiple: true.":"")}}),C.presentation==="yesNo"&&C.type!=="boolean"&&r.push({severity:"error",path:G,code:"config.yesno-non-boolean",message:{de:`Feld '${C.key}' setzt presentation: 'yesNo', hat aber den Typ '${C.type}' \u2014 nur 'boolean'-Felder lassen sich als Ja | Nein-Antwort darstellen.`,en:`Field '${C.key}' sets presentation: 'yesNo' but is type '${C.type}' \u2014 only 'boolean' fields can be drawn as the Yes | No answer.`}}),C.presentation==="yesNo"&&C.defaultValue!=null&&r.push({severity:"error",path:G,code:"config.yesno-default",message:{de:`Feld '${C.key}' ist eine Ja | Nein-Frage (presentation: 'yesNo') mit einem defaultValue \u2014 die Familie muss die Antwort selbst w\xE4hlen. Den defaultValue entfernen.`,en:`Field '${C.key}' is a Yes | No question (presentation: 'yesNo') with a defaultValue \u2014 the family must choose the answer themselves. Remove the defaultValue.`}}),r.push(...w5(C,G)),typeof C.minSelections=="number"&&typeof C.maxSelections=="number"&&C.minSelections>C.maxSelections&&r.push({severity:"error",path:G,code:"config.min-gt-max-selections",message:{de:`Feld '${C.key}' hat minSelections (${C.minSelections}) > maxSelections (${C.maxSelections}).`,en:`Field '${C.key}' has minSelections (${C.minSelections}) > maxSelections (${C.maxSelections}).`}});let Ce=C.enumRef;Ce!==void 0&&r.push({severity:"error",path:`${G}.enumRef`,code:"config.enum-ref-retired",message:{de:`Feld '${C.key}' nennt den entfernten Options-Katalog (enumRef '${String(Ce)}'). Die Optionen im Formular angeben (enumOptions + enumOptionLabels) oder eine Liste des Mandanten binden (enumListKey).`,en:`Field '${C.key}' names the removed option catalog (enumRef '${String(Ce)}'). Author the options in the form (enumOptions + enumOptionLabels) or bind a tenant list (enumListKey).`}}),(C.enumOptions??[]).forEach((Ae,hn)=>{let Je=V0(Ae);Je!==null&&r.push({severity:"error",path:`${G}.enumOptions[${hn}]`,code:"config.enum-option-value",message:{de:Je==="empty"?`Feld '${C.key}' hat einen leeren Enum-Optionswert \u2014 das Steuerelement kann ihn nicht tragen. Der Option einen Wert geben oder sie streichen: Ein Feld, das unbeantwortet bleiben darf, bietet bereits eine eigene Zeile zum Leeren.`:`Feld '${C.key}' hat den Enum-Optionswert '${Ae}', den die Einzelauswahl f\xFCr ihre Zeile zum Leeren reserviert. Die Option umbenennen.`,en:Je==="empty"?`Field '${C.key}' has an empty enum option value \u2014 the control cannot carry it. Give the option a value, or drop it: a field that may be left unanswered already offers its own clear row.`:`Field '${C.key}' has the enum option value '${Ae}', which the single select reserves for its clear row. Rename the option.`}})}),(C.attachments??[]).forEach((Ae,hn)=>{if("storageId"in Ae){r.push({severity:"error",path:`${G}.attachments[${hn}]`,code:"config.attachment-source",message:{de:`Anhang des Felds '${C.key}' tr\xE4gt eine rohe 'storageId' \u2014 Anh\xE4nge nennen eine Bibliotheksdatei jetzt per 'fileKey' (plexus-cli files put, dann field attach --file-key).`,en:`Field '${C.key}' attachment carries a raw 'storageId' \u2014 attachments name a library file by 'fileKey' now (plexus-cli files put, then field attach --file-key).`}});return}let Je=Ae.fileKey!==void 0&&Ae.fileKey!=="",An=Ae.url!==void 0&&Ae.url!=="";Je===An&&r.push({severity:"error",path:`${G}.attachments[${hn}]`,code:"config.attachment-source",message:{de:`Anhang des Felds '${C.key}' muss genau eines von 'fileKey' oder 'url' setzen (hat ${Je&&An?"beide":"keines"}).`,en:`Field '${C.key}' attachment must set exactly one of 'fileKey' or 'url' (got ${Je&&An?"both":"neither"}).`}}),Ae.renderAs==="inlineLink"&&Ae.label===void 0&&r.push({severity:"error",path:`${G}.attachments[${hn}]`,code:"config.attachment-inline-link-label",message:{de:`inlineLink-Anhang des Felds '${C.key}' braucht ein 'label' \u2014 die verlinkte Wendung im Feldlabel.`,en:`Field '${C.key}' inlineLink attachment needs a 'label' \u2014 the linked phrase shown in the field label.`}})})},"considerField");O.fields.forEach((C,G)=>K(C,`${N}.fields[${G}]`)),O.groups?.forEach((C,G)=>{C.fields.forEach((ae,ce)=>K(ae,`${N}.groups[${G}].fields[${ce}]`))}),O.repeated?.forEach((C,G)=>{C.itemTemplate.forEach((ae,ce)=>{let Ce=`${N}.repeated[${G}].itemTemplate[${ce}]`;K(ae,Ce),ae.type==="consent"&&r.push({severity:"error",path:Ce,code:"config.consent-in-repeated",message:{de:`Feld '${ae.key}' ist eine Zustimmung in einem Wiederholungsblock \u2014 Zustimmungen stehen nur als Feld eines Abschnitts oder einer Gruppe.`,en:`Field '${ae.key}' is a consent inside a repeated block \u2014 a consent stands only as a field of a section or a group.`}})})}),O.subsections?.forEach((C,G)=>A(C,`${N}.subsections[${G}]`))}s(A,"visitFieldConfig"),e.sections.forEach((O,N)=>A(O,`sections[${N}]`)),e.effects.forEach((O,N)=>{if(O.kind==="person"){r.push(...Y0(O,e.effects,`effects[${N}]`,K=>l.has(K)));return}O.kind==="organization"&&O.nameFrom?.forEach((K,C)=>{l.has(K)||r.push({severity:"error",path:`effects[${N}].nameFrom[${C}]`,code:"ref.unknown-name-field",message:{de:`Effekt '${O.id}': nameFrom verweist auf das unbekannte Feld '${K}'.`,en:`Effect '${O.id}' nameFrom references unknown field '${K}'.`}})})});let I=s((O,N)=>{if(O.kind!=="person"&&O.kind!=="organization")return;let K=O.display;if(!K){r.push({severity:"error",path:`${N}.display`,code:"display.missing",message:{de:`Effekt '${O.id}' deklariert einen Partei-Bucket, aber kein display \u2014 Titel, Icon und Akzentfarbe der Partei w\xE4ren nicht aufl\xF6sbar.`,en:`Effect '${O.id}' declares a party bucket but no display \u2014 the party's title, icon and accent colour could not be resolved.`}});return}j0(K.icon)||r.push({severity:"error",path:`${N}.display.icon`,code:"display.unknown-icon",message:{de:`Effekt '${O.id}': display.icon '${K.icon}' ist kein bekanntes Bucket-Icon.`,en:`Effect '${O.id}' display.icon '${K.icon}' is not a known bucket icon.`}}),B0(K.color)||r.push({severity:"error",path:`${N}.display.color`,code:"display.unknown-color",message:{de:`Effekt '${O.id}': display.color '${K.color}' ist keine bekannte Bucket-Farbe.`,en:`Effect '${O.id}' display.color '${K.color}' is not a known bucket colour.`}})},"checkBucketDisplay");e.effects.forEach((O,N)=>I(O,`effects[${N}]`));let _=new Set,T=s(O=>{O.kind==="person"?_.add(O.bucket):O.kind==="organization"&&_.add(O.id.replace(/^o\./,""))},"declareBucket");e.effects.forEach(T);let b=new Set,R=s(O=>{for(let N of O)N.repeated?.forEach(K=>K.effects?.forEach(C=>T(C))),R(N.subsections??[])},"collectRepeatedBuckets");R(e.sections);let q=s((O,N)=>{_.size!==0&&O.forEach((K,C)=>{K.bucket===void 0||_.has(K.bucket)||r.push({severity:"error",path:`${N}[${C}].bucket`,code:"bucket.undeclared",message:{de:`Feld '${K.key}' geh\xF6rt zum Bucket '${K.bucket}', aber kein Person-/Organisations-Effekt deklariert ihn \u2014 das Feld geh\xF6rt zu keiner Partei.`,en:`Field '${K.key}' belongs to bucket '${K.bucket}', but no person/organization effect declares it \u2014 the field belongs to no party.`}})})},"checkFieldBuckets"),P=s((O,N)=>{if(b.has(O))return;b.add(O);let K=`sections[${N.join(".")}]`;q(O.fields,`${K}.fields`),O.groups?.forEach((C,G)=>q(C.fields,`${K}.groups[${G}].fields`)),O.repeated?.forEach((C,G)=>q(C.itemTemplate,`${K}.repeated[${G}].itemTemplate`)),O.subsections?.forEach((C,G)=>P(C,[...N,G]))},"visitBucketSection");e.sections.forEach((O,N)=>P(O,[N]));let J=e.effects.flatMap((O,N)=>O.kind==="person"&&O.subject===!0?[{e:O,i:N}]:[]);J.length>1&&J.slice(1).forEach(({e:O,i:N})=>{r.push({severity:"error",path:`effects[${N}].subject`,code:"subject.duplicate",message:{de:`Effekt '${O.id}' deklariert subject:true, aber '${J[0].e.id}' tut es bereits. Genau ein Bucket darf das Subjekt der Bewerbung sein.`,en:`Effect '${O.id}' declares subject:true, but '${J[0].e.id}' already does. Exactly one bucket may be the application subject.`}})}),e.effects.forEach((O,N)=>{if(!(O.kind!=="person"||O.nationalityFrom===void 0)){if(O.subject!==!0){r.push({severity:"error",path:`effects[${N}].nationalityFrom`,code:"nationality.not-subject",message:{de:`Effekt '${O.id}' deklariert nationalityFrom, ist aber nicht das Subjekt der Bewerbung \u2014 die Staatsangeh\xF6rigkeit wird nur f\xFCr das Subjekt der Bewerbung gelesen.`,en:`Effect '${O.id}' declares nationalityFrom but is not the application subject \u2014 nationality is read only for the application subject.`}});return}if(O.nationalityFrom.length===0){r.push({severity:"error",path:`effects[${N}].nationalityFrom`,code:"nationality.empty",message:{de:`Effekt '${O.id}' deklariert ein leeres nationalityFrom \u2014 weglassen oder mindestens ein Feld nennen.`,en:`Effect '${O.id}' declares an empty nationalityFrom \u2014 omit it or name at least one field.`}});return}O.nationalityFrom.forEach((K,C)=>{l.has(K)||r.push({severity:"error",path:`effects[${N}].nationalityFrom[${C}]`,code:"nationality.unknown-field",message:{de:`Effekt '${O.id}': nationalityFrom verweist auf das unbekannte Feld '${K}'.`,en:`Effect '${O.id}' nationalityFrom references unknown field '${K}'.`}})})}});let Y=e.effects.flatMap((O,N)=>O.kind==="person"&&O.contractParty!==void 0?[{e:O,i:N,decl:O.contractParty}]:[]);if(Y.length>0){let O=new Map;Y.forEach(({e:K,i:C})=>{let G=O.get(K.bucket);if(G===void 0){O.set(K.bucket,K.id);return}r.push({severity:"error",path:`effects[${C}].contractParty`,code:"contractParty.duplicate-bucket",message:{de:`Effekt '${K.id}' deklariert eine Vertragspartei auf Bucket '${K.bucket}', aber '${G}' tut es bereits. Ein Bucket ist h\xF6chstens eine Vertragspartei.`,en:`Effect '${K.id}' declares a contract party on bucket '${K.bucket}', but '${G}' already does. A bucket is at most one contract party.`}})});let N=Y.filter(({decl:K})=>K.role==="beneficiary");N.slice(1).forEach(({e:K,i:C})=>{r.push({severity:"error",path:`effects[${C}].contractParty.role`,code:"contractParty.duplicate-beneficiary",message:{de:`Effekt '${K.id}' deklariert contractParty.role 'beneficiary', aber '${N[0].e.id}' tut es bereits. Genau ein Bucket darf Leistungsempf\xE4nger sein.`,en:`Effect '${K.id}' declares contractParty.role 'beneficiary', but '${N[0].e.id}' already does. Exactly one bucket may be the beneficiary.`}})}),N.forEach(({e:K,i:C})=>{K.subject!==!0&&r.push({severity:"error",path:`effects[${C}].contractParty.role`,code:"contractParty.beneficiary-not-subject",message:{de:`Effekt '${K.id}' ist der Leistungsempf\xE4nger des Vertrags, aber nicht das Subjekt der Bewerbung. Leistungsempf\xE4nger und Subjekt der Bewerbung sind dieselbe Person \u2014 subject:true auf '${K.id}' setzen.`,en:`Effect '${K.id}' is the contract beneficiary but not the application subject. The beneficiary and the application subject are the same person \u2014 set subject:true on '${K.id}'.`}})}),J.forEach(({e:K,i:C})=>{let G=K.contractParty?.role;G!==void 0&&G!=="beneficiary"&&r.push({severity:"error",path:`effects[${C}].contractParty.role`,code:"contractParty.subject-role-mismatch",message:{de:`Effekt '${K.id}' ist das Subjekt der Bewerbung, deklariert aber contractParty.role '${G}'. Das Subjekt der Bewerbung ist der Leistungsempf\xE4nger des Vertrags.`,en:`Effect '${K.id}' is the application subject but declares contractParty.role '${G}'. The application subject is the contract beneficiary.`}})}),Y.some(({decl:K})=>K.signs===!0)||r.push({severity:"error",path:"effects",code:"contractParty.no-signer",message:{de:"Das Formular deklariert Vertragsparteien, aber keine unterschreibt (contractParty.signs). Ein Vertrag ohne Unterzeichner kann nicht erzeugt werden.",en:"The form declares contract parties, but none signs (contractParty.signs). A contract without a signatory cannot be generated."}})}e.effects.forEach((O,N)=>{O.kind==="fieldMap"&&O.mappings.forEach((K,C)=>{a.has(K.from)||r.push({severity:"error",path:`effects[${N}].mappings[${C}].from`,code:"ref.unknown-fieldmap-from",message:{de:`Effekt '${O.id}': fieldMap from '${K.from}' verweist auf ein unbekanntes Feld.`,en:`Effect '${O.id}' fieldMap from '${K.from}' references unknown field.`}})})});for(let[O,N]of u){if(!N.sameAs)continue;let K=`fields[${O}].sameAs`,C=u.get(N.sameAs.source);C===void 0||N.sameAs.source===O?r.push({severity:"error",path:`${K}.source`,code:"ref.unknown-sameas-source",message:{de:N.sameAs.source===O?`Feld '${O}': sameAs.source verweist auf sich selbst.`:`Feld '${O}': sameAs.source verweist auf das unbekannte Feld '${N.sameAs.source}' (muss ein Abschnitts- oder Gruppenfeld sein).`,en:N.sameAs.source===O?`Field '${O}' sameAs.source references itself.`:`Field '${O}' sameAs.source references unknown field '${N.sameAs.source}' (must be a top-level or group field).`}}):C.type!==N.type?r.push({severity:"error",path:`${K}.source`,code:"ref.unknown-sameas-source",message:{de:`Feld '${O}' (${N.type}): sameAs.source '${N.sameAs.source}' hat einen anderen Typ (${C.type}) \u2014 die Spiegelung muss formgleich sein.`,en:`Field '${O}' (${N.type}) sameAs.source '${N.sameAs.source}' has a different type (${C.type}) \u2014 the mirror must be shape-identical.`}}):C.sameAs&&r.push({severity:"error",path:`${K}.source`,code:"ref.unknown-sameas-source",message:{de:`Feld '${O}': sameAs.source '${N.sameAs.source}' deklariert selbst sameAs \u2014 Spiegelketten werden nicht unterst\xFCtzt.`,en:`Field '${O}' sameAs.source '${N.sameAs.source}' itself declares sameAs \u2014 mirror chains are not supported.`}});let G=u.get(N.sameAs.toggle);(G===void 0||G.type!=="boolean")&&r.push({severity:"error",path:`${K}.toggle`,code:"ref.unknown-sameas-toggle",message:{de:G===void 0?`Feld '${O}': sameAs.toggle verweist auf das unbekannte Feld '${N.sameAs.toggle}'.`:`Feld '${O}': sameAs.toggle '${N.sameAs.toggle}' muss den Typ 'boolean' haben (ist '${G.type}').`,en:G===void 0?`Field '${O}' sameAs.toggle references unknown field '${N.sameAs.toggle}'.`:`Field '${O}' sameAs.toggle '${N.sameAs.toggle}' must be type 'boolean' (got '${G.type}').`}}),N.required===!0&&r.push({severity:"error",path:`fields[${O}].required`,code:"config.sameas-static-required",message:{de:`Feld '${O}' deklariert sameAs, ist aber statisch Pflicht \u2014 solange es gespiegelt ist, hat es keinen eigenen Wert, die Slice-Validierung beim Commit w\xFCrde immer scheitern. required: false + requiredIf: "${N.sameAs.toggle} != true" verwenden.`,en:`Field '${O}' declares sameAs but is statically required \u2014 while mirrored it holds no own value, so commit-time slice validation would always fail. Use required: false + requiredIf: "${N.sameAs.toggle} != true".`}})}{let O=new Map;e.effects.forEach(N=>O.set(N.id,N.kind)),e.effects.forEach((N,K)=>{if(N.kind!=="shareValue")return;[["from",N.from],["to",N.to]].forEach(([ae,ce])=>{let Ce=O.get(ce.slice(1));Ce!==void 0&&Ce!=="person"&&Ce!=="organization"&&r.push({severity:"error",path:`effects[${K}].${ae}`,code:"ref.sharevalue-endpoint",message:{de:`Effekt '${N.id}': shareValue ${ae} '${ce}' muss auf einen Person-/Organisations-Effekt verweisen (ist '${Ce}').`,en:`Effect '${N.id}' shareValue ${ae} '${ce}' must reference a person/organization effect (got '${Ce}').`}})});let C=N.from.slice(1);e.effects.some(ae=>ae.kind==="fieldMap"&&ae.target.slice(1)===C&&ae.mappings.some(ce=>ce.to===N.field)||ae.kind==="shareValue"&&ae.id!==N.id&&ae.to.slice(1)===C&&ae.field===N.field)||r.push({severity:"error",path:`effects[${K}].field`,code:"config.sharevalue-missing-source-map",message:{de:`Effekt '${N.id}' teilt das Feld '${N.field}' aus '${N.from}', aber kein fieldMap mit Ziel '${N.from}' bildet auf '${N.field}' ab (und kein shareValue verkn\xFCpft es) \u2014 der Quellwert k\xF6nnte beim Commit nie existieren.`,en:`Effect '${N.id}' shares field '${N.field}' from '${N.from}', but no fieldMap targeting '${N.from}' maps to '${N.field}' (and no shareValue links it in) \u2014 the source value could never exist at commit time.`}})})}e.effects.forEach((O,N)=>{O.kind==="person"&&O.bucket.includes(Ur)&&r.push({severity:"error",path:`effects[${N}].bucket`,code:"config.bucket-name-contains-hash",message:{de:`Effekt '${O.id}': bucket '${O.bucket}' darf '${Ur}' nicht enthalten (f\xFCr den Zeilen-Namensraum reserviert).`,en:`Effect '${O.id}' bucket '${O.bucket}' must not contain '${Ur}' (reserved for the per-row namespace).`}}),O.kind==="organization"&&O.orgKind.includes(Ur)&&r.push({severity:"error",path:`effects[${N}].orgKind`,code:"config.bucket-name-contains-hash",message:{de:`Effekt '${O.id}': orgKind '${O.orgKind}' darf '${Ur}' nicht enthalten (f\xFCr den Zeilen-Namensraum reserviert).`,en:`Effect '${O.id}' orgKind '${O.orgKind}' must not contain '${Ur}' (reserved for the per-row namespace).`}})});let fe=new Set;function Q(O,N){O.repeated?.forEach((K,C)=>{let G=K.effects??[];if(G.length>0){let ae=`${N}.repeated[${C}]`,ce=new Set(G.map(oe=>oe.id)),Ce=new Set(K.itemTemplate.map(oe=>oe.key)),Ae=(K.uniqueBy?.length??0)>0,hn=s(oe=>oe.startsWith("$item.")?Ce.has(oe.slice(6)):l.has(oe),"resolvesName"),Je=s(oe=>oe.startsWith("$item.")?Ce.has(oe.slice(6)):a.has(oe),"resolvesFrom"),An=s(oe=>{let Kn=oe.slice(1);return ce.has(Kn)||m.has(Kn)},"resolvesRef");G.forEach((oe,Kn)=>{let gn=`${ae}.effects[${Kn}]`;if(m.has(oe.id)||fe.has(oe.id)?r.push({severity:"error",path:gn,code:"duplicate.repeated-effect-id",message:{de:`Der Effekt '${oe.id}' der Wiederholung ist mehrfach deklariert.`,en:`Repeated effect id '${oe.id}' is declared more than once.`}}):fe.add(oe.id),oe.kind==="person"||oe.kind==="organization"){I(oe,gn),oe.kind==="person"&&oe.subject===!0&&r.push({severity:"error",path:`${gn}.subject`,code:"subject.in-repeated",message:{de:`Effekt '${oe.id}' der Wiederholung deklariert subject:true \u2014 eine Zeile gilt je Zeile, das Subjekt der Bewerbung je Bewerbung. Das Subjekt an einem Effekt der obersten Ebene deklarieren.`,en:`Repeated effect '${oe.id}' declares subject:true \u2014 a repeated row is per-row, the application subject is per-application. Declare the subject on a top-level effect.`}}),oe.kind==="person"&&oe.nationalityFrom!==void 0&&r.push({severity:"error",path:`${gn}.nationalityFrom`,code:"nationality.not-subject",message:{de:`Effekt '${oe.id}' der Wiederholung deklariert nationalityFrom \u2014 nur das Subjekt der Bewerbung (ein Effekt der obersten Ebene) tr\xE4gt es.`,en:`Repeated effect '${oe.id}' declares nationalityFrom \u2014 only the application subject (a top-level effect) carries it.`}}),oe.kind==="person"&&oe.contractParty!==void 0&&r.push({severity:"error",path:`${gn}.contractParty`,code:"contractParty.in-repeated",message:{de:`Effekt '${oe.id}' der Wiederholung deklariert contractParty \u2014 wer unterschreibt, wird einmal je Bewerbung deklariert, nicht je Zeile. An einem Effekt der obersten Ebene deklarieren.`,en:`Repeated effect '${oe.id}' declares contractParty \u2014 who signs is declared once per application, not once per row. Declare it on a top-level effect.`}}),Ae||r.push({severity:"error",path:ae,code:"config.repeated-effect-requires-uniqueBy",message:{de:`Wiederholung '${K.key}' hat einen Parteien erzeugenden Effekt '${oe.id}', aber kein 'uniqueBy' \u2014 Parteien je Zeile brauchen einen stabilen Identit\xE4tsschl\xFCssel.`,en:`Repeated def '${K.key}' has a party-creating effect '${oe.id}' but no 'uniqueBy' \u2014 per-row parties need a stable identity key.`}});let De=oe.kind==="person"?oe.bucket:oe.orgKind;De.includes(Ur)&&r.push({severity:"error",path:`${gn}.${oe.kind==="person"?"bucket":"orgKind"}`,code:"config.bucket-name-contains-hash",message:{de:`Effekt '${oe.id}' der Wiederholung: ${oe.kind==="person"?"bucket":"orgKind"} '${De}' darf '${Ur}' nicht enthalten.`,en:`Repeated effect '${oe.id}' ${oe.kind==="person"?"bucket":"orgKind"} '${De}' must not contain '${Ur}'.`}}),oe.kind==="person"&&r.push(...Y0(oe,G,gn,hn)),oe.kind==="organization"&&oe.nameFrom?.forEach((Ue,Ot)=>{hn(Ue)||r.push({severity:"error",path:`${gn}.nameFrom[${Ot}]`,code:"ref.unknown-name-field",message:{de:`Effekt '${oe.id}' der Wiederholung: nameFrom verweist auf das unbekannte Feld '${Ue}'.`,en:`Repeated effect '${oe.id}' nameFrom references unknown field '${Ue}'.`}})}),oe.identity?.strategy==="keyed"&&oe.identity.keyFrom.forEach((Ue,Ot)=>{Je(Ue)||r.push({severity:"error",path:`${gn}.identity.keyFrom[${Ot}]`,code:"ref.unknown-fieldmap-from",message:{de:`Effekt '${oe.id}' der Wiederholung: identity.keyFrom verweist auf das unbekannte Feld '${Ue}'.`,en:`Repeated effect '${oe.id}' identity.keyFrom references unknown field '${Ue}'.`}})})}else if(oe.kind==="relationship"){if([["from",oe.from],["to",oe.to]].forEach(([De,Ue])=>{An(Ue)||r.push({severity:"error",path:`${gn}.${De}`,code:"ref.unknown-repeated-effect",message:{de:`Beziehung '${oe.id}' der Wiederholung: ${De} verweist auf den unbekannten Effekt '${Ue}'.`,en:`Repeated relationship '${oe.id}' ${De} references unknown effect '${Ue}'.`}})}),oe.meta)for(let[De,Ue]of Object.entries(oe.meta))typeof Ue=="string"&&Ue.startsWith("$")&&!An(Ue)&&r.push({severity:"error",path:`${gn}.meta.${De}`,code:"ref.unknown-repeated-effect",message:{de:`Beziehung '${oe.id}' der Wiederholung: meta.${De} verweist auf den unbekannten Effekt '${Ue}'.`,en:`Repeated relationship '${oe.id}' meta.${De} references unknown effect '${Ue}'.`}})}else oe.kind==="fieldMap"?(An(oe.target)||r.push({severity:"error",path:`${gn}.target`,code:"ref.unknown-repeated-effect",message:{de:`fieldMap '${oe.id}' der Wiederholung: Ziel verweist auf den unbekannten Effekt '${oe.target}'.`,en:`Repeated fieldMap '${oe.id}' target references unknown effect '${oe.target}'.`}}),oe.mappings.forEach((De,Ue)=>{Je(De.from)||r.push({severity:"error",path:`${gn}.mappings[${Ue}].from`,code:"ref.unknown-fieldmap-from",message:{de:`fieldMap '${oe.id}' der Wiederholung: from '${De.from}' verweist auf ein unbekanntes Feld.`,en:`Repeated fieldMap '${oe.id}' from '${De.from}' references unknown field.`}})})):oe.kind==="shareValue"&&r.push({severity:"error",path:gn,code:"config.sharevalue-in-repeated",message:{de:`Effekt '${oe.id}' der Wiederholung: shareValue wird in Effekten von Wiederholungszeilen nicht unterst\xFCtzt.`,en:`Repeated effect '${oe.id}': shareValue is not supported inside repeated row effects.`}})})}}),O.subsections?.forEach((K,C)=>Q(K,`${N}.subsections[${C}]`))}s(Q,"visitRepeatedEffects"),e.sections.forEach((O,N)=>Q(O,`sections[${N}]`));let re=R0(t.effects);return re.hasCycle&&r.push({severity:"error",path:"effects",code:"graph.effect-cycle",message:{de:`Der Effektgraph enth\xE4lt einen Zyklus: ${re.cycle?.join(" \u2192 ")??"?"}`,en:`Effect graph contains a cycle: ${re.cycle?.join(" \u2192 ")??"?"}`}}),r.push(...y5(e)),r}s(H0,"validateForm");function y5(e){let n={...e,effects:e.effects.map(J0),sections:e.sections.map(Q0),testScenarios:e.testScenarios?.map(t=>({id:t.id,label:t.label,description:t.description}))};return op(n,"form").map(t=>({severity:"error",path:t.path,code:"i18n.missing-translation",message:Sw(t)}))}s(y5,"missingTranslationIssues");function J0(e){if(!("subject"in e))return e;let{subject:n,...t}=e;return t}s(J0,"withoutSubjectFlag");function Q0(e){return{...e,repeated:e.repeated?.map(n=>({...n,effects:n.effects?.map(J0)})),subsections:e.subsections?.map(Q0)}}s(Q0,"withoutRowSubjectFlags");function U0(e,n){let t=e.reviewRequired;return t===void 0||t===!0?[]:[{severity:"error",path:n,code:"review.shape",message:{de:`Feld '${e.key}' setzt reviewRequired auf ${JSON.stringify(t)} \u2014 erlaubt ist nur true; ein nicht pr\xFCfpflichtiges Feld l\xE4sst die Angabe weg.`,en:`Field '${e.key}' sets reviewRequired to ${JSON.stringify(t)} \u2014 only true is allowed; a field that needs no review omits it.`}}]}s(U0,"reviewRequiredShapeIssues");function G0(e,n){if(!e.export)return[];let t=[];return e.type==="docRef"&&t.push({severity:"error",path:n,code:"export.invalid-type",message:{de:`Feld '${e.key}' (docRef) kann nicht exportiert werden \u2014 ein Speicher-Handle ist kein bindbarer Dokumentwert.`,en:`Field '${e.key}' (docRef) cannot be exported \u2014 a storage handle is not a bindable document value.`}}),e.multiple===!0&&t.push({severity:"error",path:n,code:"export.multiple-enum",message:{de:`Feld '${e.key}' ist eine Mehrfachauswahl \u2014 N gew\xE4hlte Optionen sind kein einzelnes zusammengesetztes Blatt, deshalb nicht exportierbar.`,en:`Field '${e.key}' is a multi-select \u2014 N picked options are not one compound leaf, so it cannot be exported.`}}),t}s(G0,"exportGateIssues");function ka(e,n,t,r,i){e.has(n)?i.push({severity:"error",path:t,code:r,message:{de:`Mehrfach vergeben: ${z0(r,"de")} '${n}'`,en:`Duplicate ${z0(r,"en")}: '${n}'`}}):e.add(n)}s(ka,"reportIfDup");function z0(e,n){let t=s((r,i)=>n==="de"?r:i,"label");switch(e){case"duplicate.section-id":return t("Abschnitts-ID","section id");case"duplicate.field-key":return t("Feldschl\xFCssel","field key");case"duplicate.effect-id":return t("Effekt-ID","effect id");case"duplicate.outcome-id":return t("Ergebnis-ID","outcome id");case"ref.unknown-required-for-outcome":return t("requiredFor-Ergebnis","requiredFor outcome");default:return e}}s(z0,"labelForCode");function Bv(e,n,t,r,i,o){e.visibleIf&&(xr(e.visibleIf,`${n}.visibleIf`,t,r,o),ba(e.visibleIf,`${n}.visibleIf`,i,o)),e.requiredIf&&(xr(e.requiredIf,`${n}.requiredIf`,t,r,o),ba(e.requiredIf,`${n}.requiredIf`,i,o)),e.disabledIf&&(xr(e.disabledIf,`${n}.disabledIf`,t,r,o),ba(e.disabledIf,`${n}.disabledIf`,i,o)),e.defaultValue&&xr(e.defaultValue,`${n}.defaultValue`,t,r,o)}s(Bv,"checkFieldAsts");function Vv(e){return{hasDefault:e.defaultValue!=null,isBoolean:e.type==="boolean",isYesNo:e.type==="boolean"&&e.presentation==="yesNo",isConsent:e.type==="consent"}}s(Vv,"gatingMeta");function ba(e,n,t,r){function i(o){switch(o.kind){case"binary":{(o.op==="=="||o.op==="!=")&&(W0(o.left,o.right,o.op,n,t,r),W0(o.right,o.left,o.op,n,t,r)),i(o.left),i(o.right);return}case"unary":i(o.operand);return;case"if":i(o.cond),i(o.then),i(o.else);return;case"call":o.args.forEach(i);return;case"arr":o.items.forEach(i);return;default:return}}s(i,"walk"),i(e)}s(ba,"checkGatingExpr");function W0(e,n,t,r,i,o){if(e.kind!=="ident")return;let a=i.get(e.path);if(a){if(a.isConsent&&n.kind==="bool"&&n.value===!1){o.push({severity:"error",path:r,code:"expr.consent-compare-false",message:{de:`Gating-Ausdruck vergleicht die Zustimmung '${e.path}' mit false \u2014 eine Zustimmung ist true oder leer, nie false. '${e.path} != true' verwenden.`,en:`Gating expression compares the consent '${e.path}' to false \u2014 a consent is true or empty, never false. Use '${e.path} != true'.`}});return}a.isBoolean&&(a.hasDefault||n.kind!=="null"&&n.kind==="bool"&&(a.isYesNo&&t==="=="||o.push({severity:"error",path:r,code:"expr.gating-compare-undefaulted-field",message:{de:`Gating-Ausdruck vergleicht das Boolean-Feld '${e.path}' ohne Standardwert per '${t}' mit einem Bool-Literal. In dreiwertiger Logik ist 'undefined ${t} ${n.value}' ${t==="=="?"false":"true"} \u2014 das Gate greift stillschweigend bei ungesetzten Werten. Dem Feld '${e.path}' einen 'defaultValue' geben (oder den Ausdruck umschreiben \u2014 z. B. '${e.path} != null' als ausdr\xFCckliche Gesetzt-Pr\xFCfung).`,en:`Gating expression compares undefaulted boolean field '${e.path}' to a bool literal via '${t}'. In three-valued logic, 'undefined ${t} ${n.value}' is ${t==="=="?"false":"true"} \u2014 the gate fires silently for unset values. Add a 'defaultValue' to field '${e.path}' (or rewrite the expression \u2014 e.g. '${e.path} != null' for an explicit set-check).`}})))}}s(W0,"inspectEqualityOperand");function xr(e,n,t,r,i){i.push(...hN(e,t.declaredContext,n)),i.push(...np(e,t.stageKeys,n));for(let o of xn(e))t.known.has(o)||kw(o)||r&&o.startsWith("$item.")||i.push({severity:"error",path:n,code:"ref.unknown-ident",message:{de:o.startsWith("$")?`Bezeichner '${o}' ist kein Geltungsbereich, den ein Formular liest \u2014 Umgebungsvariablen sind '$env.<key>.<field>', Wiederholungszeilen '$item.*'.`:`Bezeichner '${o}' ist weder als Feld, berechneter Schl\xFCssel noch als $item-Slot deklariert.`,en:o.startsWith("$")?`Identifier '${o}' is no scope a form reads \u2014 environment variables are '$env.<key>.<field>', repeated rows '$item.*'.`:`Identifier '${o}' is not declared as a field, computed key, or $item slot.`}})}s(xr,"checkAst");function Y0(e,n,t,r){let i=[];e.nameFrom!==void 0&&i.push({severity:"error",path:`${t}.nameFrom`,code:"person.name-from-removed",message:{de:`Effekt '${e.id}': eine Person hat kein nameFrom mehr \u2014 ihr Name ist die Feldzuordnung (fieldMap) auf ${vr.firstName} / ${vr.lastName}. nameFrom entfernen.`,en:`Effect '${e.id}': a person has no nameFrom any more \u2014 its name is the fieldMap onto ${vr.firstName} / ${vr.lastName}. Remove nameFrom.`}});let o=L0(e.id,n);q0(o)||i.push({severity:"error",path:t,code:"person.without-name-mapping",message:{de:`Effekt '${e.id}': keine Feldzuordnung (fieldMap) auf ${vr.firstName} oder ${vr.lastName} \u2014 die Person bek\xE4me keinen Namen.`,en:`Effect '${e.id}': no fieldMap onto ${vr.firstName} or ${vr.lastName} \u2014 the person would get no name.`}});for(let a of M0(o))r(a)||i.push({severity:"error",path:t,code:"ref.unknown-name-field",message:{de:`Effekt '${e.id}': der Name wird aus '${a}' gelesen, das kein eingegebenes Feld ist.`,en:`Effect '${e.id}': its name is read from '${a}', which is not an entered field.`}});return i}s(Y0,"personNameIssues");function w5(e,n){let t=[],r=e.required===!0||e.requiredIf!==void 0;return e.type==="consent"&&(e.defaultValue!=null&&t.push({severity:"error",path:n,code:"config.consent-default",message:{de:`Feld '${e.key}' ist eine Zustimmung mit einem defaultValue \u2014 zustimmen muss die Familie selbst. Den defaultValue entfernen.`,en:`Field '${e.key}' is a consent with a defaultValue \u2014 the family must give it themselves. Remove the defaultValue.`}}),e.sameAs!==void 0&&t.push({severity:"error",path:n,code:"config.consent-computed",message:{de:`Feld '${e.key}' ist eine Zustimmung, die ein anderes Feld spiegelt (sameAs) \u2014 zustimmen muss die Familie selbst. sameAs entfernen.`,en:`Field '${e.key}' is a consent mirroring another field (sameAs) \u2014 the family must give it themselves. Remove sameAs.`}}),r||t.push({severity:"error",path:n,code:"config.consent-not-required",message:{de:`Feld '${e.key}' ist eine Zustimmung, die nie verlangt wird \u2014 required: true oder requiredIf setzen, sonst Typ 'boolean' verwenden.`,en:`Field '${e.key}' is a consent nobody is asked to give \u2014 set required: true or requiredIf, or use type 'boolean'.`}})),e.type==="boolean"&&r&&e.defaultValue?.trim()==="false"&&t.push({severity:"warning",path:n,code:"config.boolean-required-default-false",message:{de:`Feld '${e.key}' ist ein Ja/Nein-Pflichtfeld, vorbelegt mit Nein \u2014 es gilt von Anfang an als ausgef\xFCllt. Ist es eine Zustimmung, Typ 'consent' verwenden.`,en:`Field '${e.key}' is a required yes/no preset to No \u2014 it counts as answered from the start. If it is a consent, use type 'consent'.`}}),t}s(w5,"consentConfigIssues");var k5="blocked";function Z0(e,n){let t={values:n};for(let r of e.outcomes){let i;try{i=un(r.when,t)}catch(o){F(`resolveActiveOutcome: outcome "${r.id}" when-expression threw: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(b5(i))return r.id===k5?null:r.id}return null}s(Z0,"resolveActiveOutcome");function b5(e){return!(e==null||e===!1||e===0||e===""||Array.isArray(e)&&e.length===0)}s(b5,"truthy");function X0(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}s(X0,"isScalar");function v5(e,n,t){for(let[r,i]of Object.entries(e))if(i!==void 0){if(X0(i)){n[r]=i;continue}if(Array.isArray(i)){n[r]=i;continue}for(let[o,a]of Object.entries(i))X0(a)&&(n[`${r}.${o}`]=a)}x5(e,n,t)}s(v5,"mergeRecord");function x5(e,n,t){let r=new Set(t);for(let i of Object.keys(e)){let o=i.indexOf("[");if(o<=0)continue;let a=i.slice(0,o);Wi(a).test(i)&&r.add(a)}for(let i of r){let o=qv(e,i),a=0;for(let l=0;l<o;l++)O0(e,i,l)&&a++;n[`${i}.count`]=a}}s(x5,"mergeRepeatedCounts");function eM(e,n,t){let r={...t};return v5(e,r,n),r}s(eM,"flattenValues");function Uv(e,n,t){return{code:e,fieldKey:n,text:t}}s(Uv,"submitIssue");function nM(e){return!(e==null||e===!1||e===0||e===""||Array.isArray(e)&&e.length===0)}s(nM,"truthyEval");function tM(e){if(e==null)return!0;if(typeof e=="string")return e.trim()==="";if(Array.isArray(e))return e.length===0;if(typeof e=="object"){let n=e;if("storageId"in n)return!(typeof n.storageId=="string"&&n.storageId.trim()!=="");let t=n;return!t.street?.trim()||!t.hausnr?.trim()||!t.plz?.trim()||!t.ort?.trim()||!t.land?.trim()}return!1}s(tM,"isEmptyValue");function S5(e,n,t){let r=!!e.required;if(!r&&e.requiredIf)try{r=nM(un(e.requiredIf,{values:n}))}catch{r=!1}return r?e.requiredFor?t===null?!1:e.requiredFor.includes(t):!0:!1}s(S5,"fieldIsLiveRequired");function A5(e,n,t){return rM(e,n,t).evalCtx}s(A5,"buildSubmitEvalContext");function rM(e,n,t){let r=E5(e),i=Object.keys(n).filter(l=>r(l)!==null),o=new Set(i),a=new Set;for(;;){let l={};for(let[y,k]of Object.entries(n))(r(y)===null||o.has(y))&&(l[y]=k);let d=iM(e,l,t),c=new Set,u=new Set;sM(e,d,y=>c.add(y.key),y=>u.add(y.key));let p=new Set(i.filter(y=>{let k=r(y);return k.kind==="field"?c.has(y):u.has(k.repeatedKey)}));if(p.size===o.size&&[...p].every(y=>o.has(y))){let y={};for(let k of i)o.has(k)||(y[k]=n[k]);return{visible:l,hidden:y,evalCtx:d}}let m=[...p].sort().join("\0");if(a.has(m)){let y=i.filter(k=>p.has(k)!==o.has(k));F(`[smartForm] visibility of ${y.join(", ")} does not settle \u2014 each depends on whether the other's value counts. The form's visibleIf conditions are contradictory.`)}a.add(m),o=p}}s(rM,"splitWithContext");function E5(e){let n=new Map,t=[];for(let r of Dm(e.sections)){for(let i of r.fields)n.set(i.key,i);for(let i of r.groups??[])for(let o of i.fields)n.set(o.key,o);for(let i of r.repeated??[])t.push({key:i.key,pattern:Wi(i.key),items:new Map(i.itemTemplate.map(o=>[o.key,o]))})}return r=>{let i=n.get(r);if(i!==void 0)return{kind:"field",field:i};for(let o of t){let a=o.pattern.exec(r);if(a!==null)return{kind:"row",repeatedKey:o.key,field:o.items.get(a[2])}}return null}}s(E5,"fieldOwnership");function iM(e,n,t){let r=[];for(let o of Dm(e.sections))for(let a of o.repeated??[])r.push(a.key);let i=eM(n,r,t);for(let o of Dm(e.sections))for(let a of o.computed??[])try{i[a.key]=un(a.expression,{values:i})}catch{}return i}s(iM,"rawEvalContext");function oM(e,n,t){let{values:r,defaulted:i}=T5(e,n,t),o=rM(e,r,t),a={};for(let[l,d]of Object.entries(o.hidden))i.has(l)||(a[l]=d);return{...o,hidden:a}}s(oM,"splitDraftValues");function T5(e,n,t,r){let i={...n},o=new Set,a=null;for(let l of Dm(e.sections))for(let d of[...l.fields,...(l.groups??[]).flatMap(c=>c.fields)]){if(!d.defaultValue||n[d.key]!=null||r?.(d.key))continue;a??=iM(e,n,t);let c;try{c=un(d.defaultValue,{values:a})}catch(u){F(`[smartForm] defaultValue of '${d.key}' does not evaluate: ${u instanceof Error?u.message:String(u)}`)}c!=null&&(i[d.key]=c,o.add(d.key))}return{values:i,defaulted:o}}s(T5,"applyFieldDefaults");function Dm(e){let n=[],t=s(r=>{n.push(r);for(let i of r.subsections??[])t(i)},"walk");for(let r of e)t(r);return n}s(Dm,"walkSectionsDeep");function $5(e,n,t,r=!1){if(tM(n))return null;let i=t.fields[e.type];i||F(`[fieldFormatIssue] no field provider registered for type "${e.type}" (field "${e.key}"). Register it in the domain form registry.`);let o=i.validate(e,n,{state:{values:{},computed:{}},testMode:r});return o.length>0?o[0].message:null}s($5,"fieldFormatIssue");function R5(e,n){return tM(n)||e.type==="consent"&&n!==!0}s(R5,"isUnanswered");function Cm(e,n){if(!e)return!0;try{return nM(un(e,{values:n}))}catch{return!1}}s(Cm,"isVisibleUnder");function sM(e,n,t,r){let i=s(o=>{if(Cm(o.visibleIf,n)){for(let a of o.fields)Cm(a.visibleIf,n)&&t(a);for(let a of o.groups??[])if(Cm(a.visibleIf,n))for(let l of a.fields)Cm(l.visibleIf,n)&&t(l);if(r!==void 0)for(let a of o.repeated??[])r(a);for(let a of o.subsections??[])i(a)}},"walk");for(let o of e.sections)i(o)}s(sM,"forEachVisibleField");function aM(e,n,t,r={}){let i=A5(e,n,t),o=[],a=Z0(e,i);a===null&&r.requireOutcome!==!1&&o.push(Uv("no-outcome",null,{de:"Die Angaben ergeben keinen g\xFCltigen Abschluss \u2014 bitte pr\xFCfen Sie das Formular.",en:"The answers do not lead to a valid outcome \u2014 please check the form."}));let l=new Set(r.exemptFromRequired??[]);return sM(e,i,d=>{let c=n[d.key];if(R5(d,c)){!l.has(d.type)&&S5(d,i,a)&&o.push(Uv("required",d.key,dl([d.label],([p],m)=>m==="de"?`${p} ist ein Pflichtfeld.`:`${p} is a required field.`)));return}if(!r.registry)return;let u=$5(d,c,r.registry,r.testMode===!0);u!==null&&o.push(Uv("format",d.key,u))}),{issues:o,activeOutcome:a,evalCtx:i,submittable:o.length===0}}s(aM,"checkSubmittable");function lM(e){let n=e.testScenarios??[];if(n.length===0)return[];let{compiled:t}=Zs(e),r=[];for(let i of n){let o=i.prefill??{};if(!cN(e,i.env))continue;let a=fN(e,i.env),{visible:l}=oM(t,o,a),d=aM(t,l,a,{exemptFromRequired:["docRef"]});for(let c of d.issues){if(c.code==="no-outcome"){r.push({severity:"error",path:`scenario:${i.id}`,code:"scenario.no-outcome",message:{de:`Szenario "${i.label.de}" erreicht kein g\xFCltiges Outcome \u2013 der Testfall ist nicht absendbar.`,en:`Scenario "${i.label.en}" reaches no valid outcome \u2013 the test case cannot be submitted.`}});continue}if(c.code==="required"){r.push({severity:"error",path:`scenario:${i.id}/${c.fieldKey}`,code:"scenario.required-field-unfilled",message:{de:`Szenario "${i.label.de}" l\xE4sst das Pflichtfeld ${c.fieldKey} unbef\xFCllt \u2013 kein g\xFCltiges Outcome.`,en:`Scenario "${i.label.en}" leaves the required field ${c.fieldKey} empty \u2013 no valid outcome.`}});continue}r.push({severity:"error",path:`scenario:${i.id}/${c.fieldKey}`,code:"scenario.invalid-value",message:dl([i.label,c.text],([u,p],m)=>m==="de"?`Szenario "${u}": ${p}`:`Scenario "${u}": ${p}`)})}}return r}s(lM,"validateScenarios");function Fm(e){return e.filter(n=>(n.severity??"error")==="error")}s(Fm,"blockingIssues");function Lm(e,n={}){return[...H0(e,n),...lM(e)]}s(Lm,"runFormValidators");function Mm(e){return Fm(e)}s(Mm,"blockingFormErrors");function dM(e,n,t){return A_(e,n,t)}s(dM,"runWorkflowValidators");function cM(e){return Fm(e)}s(cM,"blockingWorkflowErrors");var I5=["actionTeams","artifacts","assign","inputs","library","next","notifications","optionalActions","outcomes","outputLabels","sublabel","tasks"],uM={join:{required:[],optional:[]},end:{required:[],optional:[]},eventTrigger:{required:[],optional:[]},form:{required:[],optional:["adoptForm","formExports"]},roleAssign:{required:[],optional:[]},setFlag:{required:[],optional:[]},if:{required:["condition"],optional:[]},countersign:{required:["contract"],optional:["signing","titles"]},engagePush:{required:["form"],optional:["contract","engage","payment"]},decision:{required:[],optional:["commentRequired","decisionAsTask","formView","reads","requiresOneOf"]},review:{required:[],optional:["commentRequired","decisionAsTask","form"]},waitlist:{required:[],optional:[]},completenessCheck:{required:["deadline","requires"],optional:[]},collectPayment:{required:[],optional:[]},governedDocument:{required:["approval","production","responseStrategy"],optional:["confirmBeforeIssue","confirmContractTerms","contractTermsQuestionText","form","generatorStamp","reads","responseLabels","templateStamp","titles"]}},pt={id:w.string(),label:ua,actionTeams:w.optional(w.any()),artifacts:w.optional(w.any()),assign:w.optional(w.any()),inputs:w.optional(w.any()),library:w.optional(w.any()),next:w.optional(w.any()),notifications:w.optional(w.any()),optionalActions:w.optional(w.any()),outcomes:w.optional(w.any()),outputLabels:w.optional(w.any()),sublabel:w.optional(w.any()),tasks:w.optional(w.any())},O5=w.object({...pt,type:w.literal("join")}),P5=w.object({...pt,type:w.literal("end")}),N5=w.object({...pt,type:w.literal("eventTrigger")}),_5=w.object({...pt,type:w.literal("form"),adoptForm:w.optional(w.any()),formExports:w.optional(w.any())}),C5=w.object({...pt,type:w.literal("roleAssign")}),D5=w.object({...pt,type:w.literal("setFlag")}),F5=w.object({...pt,type:w.literal("if"),condition:w.optional(w.any())}),L5=w.object({...pt,type:w.literal("countersign"),contract:w.optional(w.any()),signing:w.optional(w.any()),titles:w.optional(w.any())}),M5=w.object({...pt,type:w.literal("engagePush"),contract:w.optional(w.any()),engage:w.optional(w.any()),form:w.optional(w.any()),payment:w.optional(w.any())}),q5=w.object({...pt,type:w.literal("decision"),commentRequired:w.optional(w.any()),decisionAsTask:w.optional(w.any()),reads:w.optional(w.any()),requiresOneOf:w.optional(w.any()),formView:w.optional(w.any())}),K5=w.object({...pt,type:w.literal("review"),commentRequired:w.optional(w.any()),decisionAsTask:w.optional(w.any()),form:w.optional(w.any())}),j5=w.object({...pt,type:w.literal("waitlist")}),B5=w.object({...pt,type:w.literal("completenessCheck"),deadline:w.optional(w.any()),requires:w.optional(w.any())}),V5=w.object({...pt,type:w.literal("collectPayment")}),U5=w.object({...pt,type:w.literal("governedDocument"),approval:w.optional(w.any()),confirmBeforeIssue:w.optional(w.any()),confirmContractTerms:w.optional(w.any()),contractTermsQuestionText:w.optional(w.any()),form:w.optional(w.any()),generatorStamp:w.optional(w.any()),production:w.optional(w.any()),reads:w.optional(w.any()),responseLabels:w.optional(w.any()),responseStrategy:w.optional(w.any()),templateStamp:w.optional(w.any()),titles:w.optional(w.any())}),BDe=w.union(O5,P5,N5,_5,C5,D5,F5,L5,M5,q5,K5,j5,B5,V5,U5);function fM(e){let n=[];return e.forEach((t,r)=>{if(t===null||typeof t!="object"||Array.isArray(t)){n.push(`graph.nodes[${r}]: a node must be an object`);return}let i=t,o=`graph.nodes[${r}]${typeof i.id=="string"?` (${i.id})`:""}`;(typeof i.id!="string"||i.id==="")&&n.push(`${o}: \`id\` must be a non-empty string`);let a=i.type;if(typeof a!="string"||!(a in uM)){n.push(`${o}: unknown node type ${JSON.stringify(a)}`);return}let l=uM[a],d=new Set(["id","type","label",...I5,...l.required,...l.optional]);for(let c of Object.keys(i))d.has(c)||n.push(`${o}: \`${c}\` is not a field of a ${a} node. Delete the line.`)}),n}s(fM,"workflowNodeEnvelopeIssues");function pM(e,n){return e.enumOptionLabels?.[n]??{de:n,en:n}}s(pM,"inlineEnumOptionLabel");var hM={string:"string",boolean:"boolean",consent:"boolean",date:"date",enum:"enum",email:"email",tel:"tel",address:"address"};function gM(e){return hM[e]!==void 0}s(gM,"isExportableFieldType");function G5(e){return e.exportType===void 0&&F(`formExports: computed '${e.key}' is exported without an exportType \u2014 the publish validator should have refused this form.`),{key:e.key,type:e.exportType,label:e.label??{de:e.key,en:e.key}}}s(G5,"leafForComputed");function mM(e){let n=hM[e.type];return n===void 0&&F(`formExports: field '${e.key}' has type '${e.type}', which is not exportable \u2014 the publish validator should have refused this form.`),{key:e.key,type:n,label:e.label,...e.enumOptions!==void 0?{enumOptions:e.enumOptions.map(t=>({value:t,label:pM(e,t)}))}:{}}}s(mM,"leafFor");function Gv(e){let n=[],t=s(r=>{for(let i of r.fields)i.export===!0&&n.push(mM(i));for(let i of r.groups??[])for(let o of i.fields)o.export===!0&&n.push(mM(o));for(let i of r.computed??[])i.export===!0&&n.push(G5(i));for(let i of r.subsections??[])t(i)},"visit");for(let r of e.sections)t(r);return n}s(Gv,"exportedFormLeaves");var yM=s(e=>e,"asEffectId"),Yi=s(e=>e,"asOutcomeId"),va=s(e=>e,"asSectionId"),ot=s(e=>e,"asFieldKey");var Sr=["string","boolean","consent","date","enum","email","tel","address","docRef"],Nd=["person","organization","relationship","fieldMap"],Hi=["auto-on-any-write","auto-on-required-complete","workflow-explicit"],xa=["fresh","keyed","manual"];function Uo(e,n,t,r){if(e===void 0||e===""){if(n!==void 0&&n!=="")throw new Error(`${t}: ${r}-en needs ${r} too`);return}return ln(e,n,t,r)}s(Uo,"optionalLocalizedText");function Jn(e,n){if(!(e===void 0||e===""))try{In(e)}catch(t){throw new Error(`offer form: ${n} is not a valid expression: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}s(Jn,"assertExpression");function _d(e){return Object.keys(e.smartforms??{})}s(_d,"carriedFormSlugs");function zv(e){let t=e.workflow?.graph?.nodes??[],r=[];for(let i of t){if(i.type!=="form")continue;let o=i.inputs?.smartForm;o?.kind==="literal"&&typeof o.value=="string"&&o.value&&r.push(o.value)}return r}s(zv,"boundFormSlugs");function qm(e,n){let t=_d(e);if(n){if(!t.includes(n))throw new Error(`offer form: no smartform "${n}" in this bundle (have: ${t.join(", ")||"none"})`);return n}if(t.length===0)throw new Error("offer form: bundle carries no smartforms \u2014 run `offer form add` first");if(t.length>1)throw new Error(`offer form: bundle carries ${t.length} smartforms \u2014 pass --form <key> (one of: ${t.join(", ")})`);return t[0]}s(qm,"resolveFormSlug");function Km(e,n){let t=e.smartforms?.[n];if(!t)throw new Error(`offer form: smartform "${n}" not found in bundle`);return t}s(Km,"getForm");function Kt(e){let n=[],t=s(r=>{n.push(r),r.subsections?.forEach(i=>t(i))},"visit");return e.sections.forEach(t),n}s(Kt,"walkSections");function rr(e,n){return Kt(e).find(t=>t.id===n)}s(rr,"findSection");function Go(e,n){for(let t of Kt(e)){let r=t.fields.findIndex(i=>i.key===n);if(r>=0)return{section:t,field:t.fields[r],index:r}}}s(Go,"findField");function zo(e){let n=new Set;for(let t of Kt(e))t.fields.forEach(r=>n.add(r.key)),t.groups?.forEach(r=>r.fields.forEach(i=>n.add(i.key))),t.repeated?.forEach(r=>r.itemTemplate.forEach(i=>n.add(i.key))),t.computed?.forEach(r=>n.add(r.key));return n}s(zo,"allFieldKeys");function z5(e){let n=ln(e.label,e.labelEn,"offer form add"),t={id:va("section.allgemein"),label:{de:"Allgemein",en:"General"},fields:[]},r={id:Yi("standard"),label:{de:"Standard",en:"Standard"},when:"true",output:{includeForm:!0}};return{label:n,sections:[t],effects:[],outcomes:[r]}}s(z5,"buildSkeletonSmartForm");function jm(e,n){let{key:t,label:r}=n;if(_d(e).includes(t))throw new Error(`offer form add: smartform "${t}" already exists in this bundle`);let i=z5({key:t,label:r,...n.labelEn?{labelEn:n.labelEn}:{}});e.smartforms={...e.smartforms??{},[t]:i},e.index.smartforms={...e.index.smartforms??{},[t]:{}}}s(jm,"addForm");function wM(e,n){if(!_d(e).includes(n))throw new Error(`offer form rm: smartform "${n}" not found in bundle`);if(zv(e).includes(n))throw new Error(`offer form rm: smartform "${n}" is still bound by a form node \u2014 remove the form node first (offer workflow node rm), then the form`);return delete e.smartforms[n],e.index.smartforms&&delete e.index.smartforms[n],n}s(wM,"removeForm");function kM(e,n){let t=Km(e,n.slug);if(n.label===void 0&&n.labelEn===void 0)throw new Error("offer form set: nothing to change \u2014 pass --label/--label-en");if(n.label==="")throw new Error("offer form set: --label cannot be empty");bn(t,"label",{de:n.label,en:n.labelEn},"offer form set")}s(kM,"setForm");function bM(e,n){let t=e.workflow?.graph?.nodes;if(!Array.isArray(t))throw new Error(`${n}: the bundle carries no workflow graph (workflow.json)`);return t}s(bM,"nodesOf");function vM(e,n,t){let r=bM(e,t),i=r.find(o=>o.id===n);if(i===void 0)throw new Error(`${t}: no node "${n}" (nodes: ${r.map(o=>o.id).join(", ")})`);return i}s(vM,"nodeOf");function xM(e){return e.flatMap(n=>{if(n.type!=="form"||vt(n))return[];let t=n.inputs?.smartForm;return t?.kind==="literal"&&typeof t.value=="string"&&t.value!==""?[{node:n,slug:t.value}]:[]})}s(xM,"creatingFormNodes");function SM(e){return Mm(Lm(e)).map(n=>`[${n.code??"form"}] ${n.path?`${n.path}: `:""}${n.message.de}`)}s(SM,"formErrors");function Bm(e){let n="offer workflow restamp-exports",t=bM(e,n),r=[];for(let{node:i,slug:o}of xM(t)){let a=e.smartforms?.[o];if(a===void 0)throw new Error(`${n}: form node "${i.id}" binds smartForm "${o}", but the bundle carries no smartforms/${o}.json`);let l=a,d=SM(l);if(d.length>0)throw new Error(`${n}: smartform "${o}" is refused by the publish gate \u2014 fix it first:
|
|
11258
|
+
`)}return this.print(r,i=>i.slots.map(o=>{let a=i.override?.[o.key];return{block:o.key,label:o.label,deviates:a===void 0?"":"yes",text:(a??o.default).replace(/\s+/g," ").slice(0,80)}}),["block","label","deviates","text"]),0}},zb=class extends D{static{s(this,"NotificationsLettersSetCommand")}static paths=[["notifications","letters","set"]];static usage=$.Usage({category:"Notifications",description:"Reword one or more blocks of a letter for this school (merge \u2014 untouched blocks stay as they are).",details:"A block whose text EQUALS the platform default is dropped rather than stored: what is kept is the deviation, never a copy, so a later improvement to an untouched block still reaches this school. An unknown block or an undeclared {{placeholder}} is refused by the backend with every finding named \u2014 nothing is written.",examples:[["One paragraph",'$0 --tenant test notifications letters set applicant.welcome --locale de --slot intro="Sch\xF6n, dass Sie da sind."'],["The English letter",'$0 --tenant test notifications letters set applicant.welcome --locale en --slot intro="Lovely to have you."'],["From a file","$0 --tenant test notifications letters set applicant.tasksOpen --locale de --slot-file intro=./intro.txt"]]});templateId=f.String({required:!0});locale=f.String("--locale",{description:`Letter language (${We.join("|")}) \u2014 required; each language is worded on its own`});slot=f.Array("--slot",{description:"<blockKey>=<text> (repeatable)"});slotFile=f.Array("--slot-file",{description:"<blockKey>=<path> \u2014 read the text from a local file (repeatable)"});async execute(){let n=I6(this.slot,this.slotFile);if(Object.keys(n).length===0)throw new Error("notifications letters set: nothing to write \u2014 pass --slot <blockKey>=<text> or --slot-file <blockKey>=<path>");let t=await this.caller(),r=await t.mutation(x.notifications.saveLetterOverride,{tenantSlug:this.requireTenant(t),templateId:this.templateId,locale:Jb(this.locale,"letters set"),slots:n});return this.print({templateId:this.templateId,submitted:Object.keys(n),...r},i=>[{key:"letter",value:i.templateId},{key:"submitted",value:i.submitted.join(", ")},{key:"deviating blocks",value:i.overriddenSlotKeys.join(", ")||"\u2014 (back to the platform text)"}]),0}},Wb=class extends D{static{s(this,"NotificationsLettersResetCommand")}static paths=[["notifications","letters","reset"]];static usage=$.Usage({category:"Notifications",description:"Drop this school's deviations \u2014 named blocks, or the whole letter with --all.",details:"--all is required to drop a whole letter: dropping everything must be typed, never be what happens when a --slot is forgotten.",examples:[["One block back to the platform text","$0 --tenant test notifications letters reset applicant.welcome --locale de --slot intro"],["The whole letter","$0 --tenant test notifications letters reset applicant.welcome --locale en --all"]]});templateId=f.String({required:!0});locale=f.String("--locale",{description:`Letter language (${We.join("|")}) \u2014 required; each language is worded on its own`});slot=f.Array("--slot",{description:"Block key to reset (repeatable)"});all=f.Boolean("--all",!1,{description:"Reset every block of this letter"});async execute(){let n=(this.slot??[]).map(i=>i.trim()).filter(Boolean);if(this.all&&n.length>0)throw new Error("notifications letters reset: --all resets everything \u2014 it cannot be combined with --slot.");if(!this.all&&n.length===0)throw new Error("notifications letters reset: name the blocks with --slot <blockKey>, or pass --all to reset the whole letter.");let t=await this.caller(),r=await t.mutation(x.notifications.resetLetterOverride,{tenantSlug:this.requireTenant(t),templateId:this.templateId,locale:Jb(this.locale,"letters reset"),...this.all?{}:{slotKeys:n}});return this.print({templateId:this.templateId,reset:this.all?"all":n.join(", "),...r},i=>[{key:"letter",value:i.templateId},{key:"reset",value:i.reset},{key:"still deviating",value:i.overriddenSlotKeys.join(", ")||"\u2014 (nothing)"}]),0}},$d=s((e,n)=>e==null?n:e.replace(/\s*\n\s*/g," \u23CE "),"flatCell");function lm(e,n,t){return["de","en"].map(r=>({field:`${e} (${r})`,school:n===null?"\u2014 (platform)":n[r]===""?"\u2014 (untranslated)":$d(n[r],""),...t===null?{}:{platform:$d(t[r],"")}}))}s(lm,"chromeTextRows");var Yb=class extends D{static{s(this,"NotificationsChromeShowCommand")}static paths=[["notifications","chrome","show"]];static usage=$.Usage({category:"Notifications",description:"The school's letter frame (greeting and sign-off per language, sender name) and the platform wording each falls back to."});async execute(){let n=await this.caller(),t=await n.query(x.notifications.getTenantChrome,{tenantSlug:this.requireTenant(n)});return this.print(t,r=>[...lm("greeting",r.greeting,r.defaults.greeting),...lm("closing",r.closing,r.defaults.closing),{field:"senderName",school:$d(r.senderName,"\u2014 (platform)"),platform:$d(r.defaults.senderName,"")}],["field","school","platform"]),0}},Hb=class extends D{static{s(this,"NotificationsChromeSetCommand")}static paths=[["notifications","chrome","set"]];static usage=$.Usage({category:"Notifications",description:"Set the school's letter frame. Greeting and sign-off are set in BOTH languages at once; both EMPTY clears that field back to the platform wording.",examples:[["Own sign-off",'$0 --tenant test notifications chrome set --closing-de="Herzliche Gr\xFC\xDFe, Ihr Grundschul-Team" --closing-en="Warm regards, your primary school team"'],["Back to the platform sign-off",'$0 --tenant test notifications chrome set --closing-de="" --closing-en=""']]});greetingDe=f.String("--greeting-de",{description:"Opening line, German"});greetingEn=f.String("--greeting-en",{description:"Opening line, English"});closingDe=f.String("--closing-de",{description:"Sign-off, German"});closingEn=f.String("--closing-en",{description:"Sign-off, English"});senderName=f.String("--sender-name",{description:"Name the school signs with (empty string clears it)"});async execute(){let n=s((l,d,c)=>{if(!(d===void 0&&c===void 0)){if(d===void 0||c===void 0)throw new Error(`notifications chrome set: --${l}-de and --${l}-en go together \u2014 the frame is worded in every language`);return{de:d,en:c}}},"pair"),t=n("greeting",this.greetingDe,this.greetingEn),r=n("closing",this.closingDe,this.closingEn);if(t===void 0&&r===void 0&&this.senderName===void 0)throw new Error("notifications chrome set: nothing to change \u2014 pass --greeting-de/--greeting-en, --closing-de/--closing-en or --sender-name");let i=await this.caller(),o=this.requireTenant(i);await i.mutation(x.notifications.saveTenantChrome,{tenantSlug:o,...t!==void 0?{greeting:t}:{},...r!==void 0?{closing:r}:{},...this.senderName!==void 0?{senderName:this.senderName}:{}});let a=await i.query(x.notifications.getTenantChrome,{tenantSlug:o});return this.print(a,l=>[...lm("greeting",l.greeting,null),...lm("closing",l.closing,null),{field:"senderName",school:$d(l.senderName,"\u2014 (platform)")}],["field","school"]),0}},_F=[qb,Kb,jb,Bb,Vb,Ub,Gb,zb,Wb,Yb,Hb];var P6="-stufe-",N6=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function Qb(e){return`${e}${P6}`}s(Qb,"stageKeyPrefix");function Zb(e,n){return`${Qb(e)}${n}`}s(Zb,"stageStorageKey");function DF(e,n){let t=Qb(e);return n.startsWith(t)&&n.length>t.length}s(DF,"isUnderProgram");function Vr(e,n){let t=Qb(e);return DF(e,n)||le("CONFLICT",{de:`[stage/foreignKey] Der Stufenschl\xFCssel \u201E${n}\u201C liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${t}<key>\u201C). F\xFChren Sie die Stufe in bundle.yaml unter einem neuen Schl\xFCssel auf; der n\xE4chste Apply archiviert diese Zeile (hinter der Archivsperre) und legt die Stufe mit dem neuen Schl\xFCssel an.`,en:`[stage/foreignKey] The level key "${n}" is not under the program "${e}" (expected: "${t}<key>"). List the level in bundle.yaml under a new key; the next apply archives this row (behind the archive lock) and creates the level with the new key.`}),n.slice(t.length)}s(Vr,"bareStageKey");function dm(e){let n=[],t=new Map;return e.forEach((r,i)=>{let o=Rn(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.stages[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?n.push({code:"stage/nameMissing",index:i,message:{de:`[stage/nameMissing] ${l}: jede Klassenstufe braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[stage/nameMissing] ${l}: every stage needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&n.push({code:"stage/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){n.push({code:"stage/keyMissing",index:i,message:{de:`[stage/keyMissing] ${l}: jede Klassenstufe braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[stage/keyMissing] ${l}: every stage needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!N6.test(d)){n.push({code:"stage/keyInvalid",index:i,message:{de:`[stage/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[stage/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=t.get(d);if(c!==void 0){n.push({code:"stage/duplicateKey",index:i,message:{de:`[stage/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.stages[${c}] verwendet`,en:`[stage/duplicateKey] ${l}: key "${d}" is already used by program.stages[${c}]`}});return}t.set(d,i)}),n}s(dm,"stageSpecIssues");function CF(e){return{de:e.de.trim(),en:e.en.trim()}}s(CF,"trimmedText");function _6(e,n){let t=[];return e.de!==n.de&&t.push(`"${e.de}" \u2192 "${n.de}"`),e.en!==n.en&&t.push(`en "${e.en}" \u2192 "${n.en}"`),t.join(", ")}s(_6,"describeNameChange");function cm(e,n,t){if(e===null)return n.length>0&&F("planStageReconcile: stages exist but the offer has no program key"),t.map((a,l)=>({op:"insert",key:a.key,name:CF(a.name),...a.gradeLevel!==void 0?{gradeLevel:a.gradeLevel}:{},sequence:l+1}));let r=new Map(n.map(a=>[a.key,a])),i=new Set,o=[];t.forEach(({name:a,...l},d)=>{let c={...l,name:CF(a)},u=Zb(e,c.key);i.add(u);let p=d+1,m=r.get(u);if(m===void 0){o.push({op:"insert",key:c.key,name:c.name,...c.gradeLevel!==void 0?{gradeLevel:c.gradeLevel}:{},sequence:p});return}let y={};hs(m.name,c.name)||(y.name=[m.name,c.name]);let k=m.gradeLevel??null,g=c.gradeLevel??null;k!==g&&(y.gradeLevel=[k,g]),m.sequence!==p&&(y.sequence=[m.sequence,p]),(Object.keys(y).length>0||m.archived)&&o.push({op:"update",key:c.key,stageId:m.stageId,name:c.name,changes:y,unarchive:m.archived})});for(let a of[...n].sort((l,d)=>l.sequence-d.sequence))a.archived||i.has(a.key)||o.push({op:"archive",key:DF(e,a.key)?Vr(e,a.key):a.key,stageId:a.stageId,name:a.name});return o}s(cm,"planStageReconcile");function um(e){switch(e.op){case"insert":return`+stage ${e.key} (${e.name.de})`;case"archive":{let n=e.occupancy,t=[...n&&n.activeApplications>0?[`REFUSED: ${n.activeApplications} active application(s) \u2014 [stage/hasActiveApplications]`]:[],...n&&n.openLeads>0?[`${n.openLeads} open lead(s)`]:[]];return`-stage ${e.key} (${e.name.de})${t.length>0?` \u2014 ${t.join("; ")}`:""}`}case"update":{let n=[];if(e.unarchive&&n.push("restored"),e.changes.name&&n.push(_6(e.changes.name[0],e.changes.name[1])),e.changes.gradeLevel){let[t,r]=e.changes.gradeLevel;n.push(`grade ${t??"\u2013"} \u2192 ${r??"\u2013"}`)}return e.changes.sequence&&n.push(`position ${e.changes.sequence[0]} \u2192 ${e.changes.sequence[1]}`),`~stage ${e.key} (${n.join(", ")})`}}}s(um,"describeStageStep");var C6=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function pi(e,n){return`${e}-${n}`}s(pi,"runStorageKey");function FF(e,n){typeof n!="string"&&le("CONFLICT",{de:`[run/keyNotServed] Das Deployment liefert f\xFCr ein Schuljahr von \u201E${e}\u201C keinen Schl\xFCssel \u2014 es l\xE4uft ein \xE4lteres Release als die CLI. Nach dem n\xE4chsten Release erneut versuchen.`,en:`[run/keyNotServed] The deployment provides no key for a school year of "${e}" \u2014 it runs an older release than the CLI. Try again after the next release.`});let t=`${e}-`;return(!n.startsWith(t)||n.length===t.length)&&le("CONFLICT",{de:`[run/foreignKey] Der Schl\xFCssel \u201E${n}\u201C des Schuljahrs liegt nicht unter dem Programm \u201E${e}\u201C (erwartet: \u201E${t}<key>\u201C).`,en:`[run/foreignKey] The key "${n}" of the school year is not under the program "${e}" (expected: "${t}<key>").`}),n.slice(t.length)}s(FF,"bareRunKey");function fm(e){let n=[],t=new Map;return e.forEach((r,i)=>{let o=Rn(r.name),a=o!=="not-localized"&&!o.includes("de")?r.name.de:void 0,l=`program.runs[${i}]${a!==void 0?` ("${a}")`:""}`;o==="not-localized"||o.length===2?n.push({code:"run/nameMissing",index:i,message:{de:`[run/nameMissing] ${l}: jedes Schuljahr braucht einen \`name\` auf Deutsch und Englisch (\`{ de, en }\`)`,en:`[run/nameMissing] ${l}: every run needs a \`name\` in German and English (\`{ de, en }\`)`}}):o.length>0&&n.push({code:"run/nameUntranslated",index:i,message:{de:`[i18n/missingTranslation] ${l}.name fehlt in: ${o.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`,en:`[i18n/missingTranslation] ${l}.name is missing in: ${o.join(", ")} \u2014 every displayed text needs German and English.`}});let d=r.key;if(d==null||d===""){n.push({code:"run/keyMissing",index:i,message:{de:`[run/keyMissing] ${l}: jedes Schuljahr braucht einen stabilen \`key\` \u2014 der Name dient nur der Anzeige`,en:`[run/keyMissing] ${l}: every run needs a stable \`key\` \u2014 the name is display only`}});return}if(typeof d!="string"||!C6.test(d)){n.push({code:"run/keyInvalid",index:i,message:{de:`[run/keyInvalid] ${l}: der Schl\xFCssel ${JSON.stringify(d)} muss ein kleingeschriebener Slug sein (a-z, 0-9, einzelnes \u201E-\u201C)`,en:`[run/keyInvalid] ${l}: key ${JSON.stringify(d)} must be a lowercase slug string (a-z, 0-9, single "-")`}});return}let c=t.get(d);if(c!==void 0){n.push({code:"run/duplicateKey",index:i,message:{de:`[run/duplicateKey] ${l}: der Schl\xFCssel \u201E${d}\u201C wird bereits von program.runs[${c}] verwendet`,en:`[run/duplicateKey] ${l}: key "${d}" is already used by program.runs[${c}]`}});return}t.set(d,i)}),n}s(fm,"runSpecIssues");var D6={capacity:null,isOpen:!1},F6={capacity:null,isOpen:!0};function L6(e){return e===null||e==="unlimited"||typeof e=="number"&&Number.isInteger(e)&&e>=0}s(L6,"isCapacity");function pm(e,n){let t=[],r=n===void 0?void 0:new Set(n);return e.forEach((i,o)=>{if(i.capacities===void 0)return;let a=`program.runs[${o}] ("${i.key}")`;if(i.isOpen!==void 0&&t.push(`[capacity/runIsOpenWithCells] ${a}: \`isOpen\` on the run AND \`capacities\` \u2014 the open state lives on each cell; drop the run-level \`isOpen\``),i.capacities===null||typeof i.capacities!="object"||Array.isArray(i.capacities)){t.push(`[capacity/shape] ${a}: \`capacities\` must map stage keys to { isOpen, capacity }`);return}for(let[l,d]of Object.entries(i.capacities)){let c=`${a}.capacities.${l}`;r!==void 0&&!r.has(l)&&t.push(`[capacity/unknownStage] ${c}: no stage with key "${l}" in program.stages (have: ${[...r].join(", ")||"none"})`);let u=d;if(u===null||typeof u!="object"){t.push(`[capacity/shape] ${c}: expected { isOpen, capacity }`);continue}typeof u.isOpen!="boolean"&&t.push(`[capacity/isOpen] ${c}: \`isOpen\` must be true or false`),(!("capacity"in u)||!L6(u.capacity))&&t.push(`[capacity/value] ${c}: \`capacity\` must be a whole number \u2265 0, "unlimited", or null (unconfigured) \u2014 got ${JSON.stringify(u.capacity)}`)}}),t}s(pm,"capacitySpecIssues");function MF(e,n,t={stageKeys:[],runKeys:[]}){let r=e.programKey,i=new Map;if(r!==null)for(let c of e.stages)c.archived||i.set(Vr(r,c.key),c.stageId);let o=new Set(t.stageKeys),a=new Set(t.runKeys),l=new Map(e.runStages.map(c=>[`${c.runId}|${c.stageId}`,c])),d=[];for(let c of n){if(c.capacities===void 0)continue;let u=r===null?void 0:e.runs.find(p=>p.key===pi(r,c.key));if(u===void 0&&!a.has(c.key))throw new Error(`offer[admission]: run "${c.key}" does not exist and is not created by this apply`);for(let[p,m]of Object.entries(c.capacities)){let y=i.get(p);if(y===void 0&&!o.has(p))throw new Error(`offer[admission]: capacities of run "${c.key}" name stage "${p}", which the program does not have (have: ${[...i.keys()].join(", ")||"none"})`);let k={capacity:m.capacity,isOpen:m.isOpen},g=u!==void 0&&y!==void 0?l.get(`${u.runId}|${y}`):void 0,v=g!==void 0?{capacity:g.capacity,isOpen:g.isOpen}:u===void 0?D6:F6;v.capacity===k.capacity&&v.isOpen===k.isOpen||d.push({run:c.key,stageKey:p,from:v,to:k})}}return d}s(MF,"planRunCapacities");function LF(e){return`${e.capacity===null?"unconfigured":String(e.capacity)}/${e.isOpen?"open":"closed"}`}s(LF,"describeCell");function mm(e){return`~cap ${e.run}\xD7${e.stageKey} ${LF(e.from)} \u2192 ${LF(e.to)}`}s(mm,"describeCapacityStep");function qF(e){if(e.programKey===void 0)throw new Error("offer[admission]: the target backend predates stage keys \u2014 deploy it before running offer plan / apply / export with this CLI")}s(qF,"assertBackendHasStageKeys");async function Xb(e,n,t,r){let i=await e.query(x.programAdmin.getAngebotConfig,{client:n,offerKey:t,includeArchived:!0}),o=i.stages.map(u=>({stageId:u.stageId,key:u.key,name:u.name,...u.gradeLevel!==void 0?{gradeLevel:u.gradeLevel}:{},sequence:u.sequence,archived:u.archived}));qF(i);let a=cm(i.programKey,o,r),l=a.flatMap(u=>u.op==="archive"?[u.stageId]:[]);if(l.length===0)return a;let d=await e.query(x.programAdmin.getStageOccupancy,{client:n,offerKey:t,stageIds:l}),c=new Map(d.map(u=>[u.stageId,u]));return a.map(u=>{if(u.op!=="archive")return u;let p=c.get(u.stageId);if(p===void 0)throw new Error(`offer[admission]: no occupancy returned for stage ${u.stageId}`);return{...u,occupancy:{activeApplications:p.activeApplications,openLeads:p.openLeads}}})}s(Xb,"planStages");async function hm(e,n,t,r){let i=r.program?.runs??[];if(!i.some(c=>c.capacities!==void 0))return[];let o=t===null?{programKey:null,stages:[],runs:[],runStages:[]}:await e.query(x.programAdmin.getAngebotConfig,{client:n,offerKey:t});qF(o);let a=new Set(o.programKey===null?[]:o.stages.map(c=>Vr(o.programKey,c.key))),l=r.program?.stages?.map(c=>c.key)??[],d=o.programKey;return MF(o,i,{stageKeys:l.filter(c=>!a.has(c)),runKeys:i.map(c=>c.key).filter(c=>d===null||!o.runs.some(u=>u.key===pi(d,c)))})}s(hm,"planCapacities");async function M6(e,n,t,r){let i=(r.program?.runs??[]).map(d=>d.key);if(i.length===0)return;let o=await e.query(x.programAdmin.getAngebotConfig,{client:n,offerKey:t,includeArchived:!0}),a=o.programKey;if(a===null)return;let l=i.filter(d=>o.runs.some(c=>c.key===pi(a,d)&&c.status==="archived"));if(l.length>0)throw new Error(`offer[admission]: run(s) ${l.map(d=>`"${d}"`).join(", ")} exist only ARCHIVED \u2014 restore with \`offer run restore --run <key>\` or drop the bundle entry`)}s(M6,"assertNoArchivedRunKey");var ev={name:"admission",async scaffold(e,n,t,r){let i=t.tenant,o=t.program?.stages,a=[...dm(o??[]),...fm(t.program?.runs??[])];if(a.length>0)throw new Error(`offer[admission]: ${a.map(g=>g.message.de).join("; ")}`);let l=pm(t.program?.runs??[],o?.map(g=>g.key));if(l.length>0)throw new Error(`offer[admission]: ${l.join("; ")}`);await M6(e,i,n,t);let d=await hm(e,i,n,t),c=await e.query(x.programAdmin.getAngebotConfig,{client:i,offerKey:n}),u=q6(t);if(!u)throw new Error("offer[admission]: no unit to link \u2014 set links.unitKey or program.unitKey in bundle.yaml");let p=c.units.find(g=>g.key===u);if(!p)throw new Error(`offer[admission]: unit "${u}" not found in tenant "${i}". Available keys: ${c.units.flatMap(g=>g.key===null?[]:[g.key]).join(", ")||"(none)"}`);let m=[];if(r.dryRun||(await e.mutation(x.programAdmin.ensurePedagogyUnit,{client:i,unitId:p.unitId}),await e.mutation(x.programAdmin.createProgramForAngebot,{client:i,offerKey:n,unitId:p.unitId,...t.program?.key!==void 0?{programKey:t.program.key}:{}})),m.push(`unit=${u}`),o!==void 0)if(r.dryRun){let g=await Xb(e,i,n,o);m.push(...g.map(um))}else{let g=await e.mutation(x.programAdmin.reconcileProgramStages,{client:i,offerKey:n,stages:o.map(v=>({key:v.key,name:v.name,...v.gradeLevel!==void 0?{gradeLevel:v.gradeLevel}:{}}))});m.push(...g.steps,...g.warnings.map(v=>`warning ${v}`))}let y=r.dryRun?c:await e.query(x.programAdmin.getAngebotConfig,{client:i,offerKey:n});for(let g of t.program?.runs??[]){let v=y.programKey===null?void 0:y.runs.find(E=>E.key===pi(y.programKey,g.key));if(v!==void 0){hs(v.name,g.name)||(r.dryRun||await e.mutation(x.programAdmin.updateProgramRun,{client:i,offerKey:n,runId:v.runId,name:g.name}),m.push(`~run ${g.key} ("${_e(v.name)}" \u2192 "${_e(g.name)}")`));continue}r.dryRun||await e.mutation(x.programAdmin.addProgramRun,{client:i,offerKey:n,key:g.key,name:g.name,isOpen:g.capacities!==void 0?!1:g.isOpen??!0,...g.startDate?{startDate:g.startDate}:{},...g.endDate?{endDate:g.endDate}:{}}),m.push(`+run ${g.key} (${_e(g.name)})`)}let k=r.dryRun?d:await hm(e,i,n,t);if(!r.dryRun&&k.length>0){let g=await e.query(x.programAdmin.getAngebotConfig,{client:i,offerKey:n}),v=g.programKey;if(v===null)throw new Error("offer[admission]: capacities need a program \u2014 none was linked");for(let E of k){let A=g.runs.find(_=>_.key===pi(v,E.run))?.runId,I=g.stages.find(_=>Vr(v,_.key)===E.stageKey)?.stageId;if(A===void 0||I===void 0)throw new Error(`offer[admission]: cell ${E.run}\xD7${E.stageKey} vanished between plan and write`);await e.mutation(x.programAdmin.setRunStageCapacity,{client:i,offerKey:n,runId:A,stageId:I,capacity:E.to.capacity,isOpen:E.to.isOpen})}}return m.push(...k.map(mm)),m.join(", ")}};function q6(e){let n=e.program?.unitKey,t=e.links?.unitKey;if(n!==void 0&&t!==void 0&&n!==t)throw new Error(`offer[admission]: bundle.yaml names two units \u2014 program.unitKey "${n}" and links.unitKey "${t}"; keep one`);return n??t}s(q6,"bundleUnitKey");var KF={role:"control",effect:"pure",cardinality:"N-to-1"};var gm=["add","remove","replace"];function jF(e,n){let t=e.inputs?.[n];if(!(!t||t.kind!=="literal"))return t.value!=null?String(t.value):void 0}s(jF,"roleAssignLiteral");var BF={role:"method",effect:"context-mutation",inputs:s(()=>[{id:"person",label:{de:"Person",en:"Person"},type:"personRef",required:!0},{id:"roleKey",label:{de:"Rolle",en:"Role"},type:"roleKey",required:!0,optionSource:"tenantRoles"},{id:"mode",label:{de:"Modus",en:"Mode"},type:"enum",defaultValue:"add",optionSource:"declared",enumOptions:[{value:"add",label:{de:"Rolle hinzuf\xFCgen",en:"Add role"}},{value:"remove",label:{de:"Rolle entziehen",en:"Remove role"}},{value:"replace",label:{de:"Alle Rollen ersetzen",en:"Replace all roles"}}]}],"inputs"),validate:s((e,n,t)=>{let r=[],i=jF(e,"roleKey")?.trim()??"",o=jF(e,"mode")??"add";return i===""?r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.roleKey`,reason:{de:`[roleAssign/missingRoleKey] roleAssign-Knoten "${e.id}" nennt keine Rolle \u2014 welche Rolle vergeben wird, muss der Autor aus dem Rollenkatalog des Mandanten w\xE4hlen.`,en:`[roleAssign/missingRoleKey] roleAssign node "${e.id}" names no role \u2014 the author must choose which role is assigned from the school's role catalog.`},severity:"error"}):t?.roleKeys!==void 0&&!t.roleKeys.has(i)?r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.roleKey`,reason:{de:`[roleAssign/unknownRoleKey] Rolle "${i}" existiert nicht im Rollenkatalog des Mandanten \u2014 der Knoten w\xFCrde bei jeder Ausf\xFChrung abbrechen. Bekannte Rollen: ${[...t.roleKeys].sort().join(", ")}.`,en:`[roleAssign/unknownRoleKey] Role "${i}" does not exist in the school's role catalog \u2014 the node would abort on every run. Known roles: ${[...t.roleKeys].sort().join(", ")}.`},severity:"error"}):t?.assignableRoleKeys!==void 0&&!t.assignableRoleKeys.has(i)&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.roleKey`,reason:{de:`[roleAssign/nonLeafRoleKey] Rolle "${i}" hat untergeordnete Rollen und ist deshalb nicht vergebbar \u2014 eine Partei bekommt ein Blatt, keine Oberkategorie. Vergebbare Rollen: ${[...t.assignableRoleKeys].sort().join(", ")}.`,en:`[roleAssign/nonLeafRoleKey] Role "${i}" has sub-roles and therefore cannot be assigned \u2014 a party gets a leaf role, not a parent category. Assignable roles: ${[...t.assignableRoleKeys].sort().join(", ")}.`},severity:"error"}),gm.includes(o)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.mode`,reason:{de:`[roleAssign/unknownMode] roleAssign-Knoten "${e.id}" deklariert Modus "${o}" \u2014 erlaubt sind ${gm.join(" | ")}.`,en:`[roleAssign/unknownMode] roleAssign node "${e.id}" declares mode "${o}" \u2014 allowed are ${gm.join(" | ")}.`},severity:"error"}),r},"validate")};var K6=["event","effect","outcomes"],nv=s((e,n,t)=>({layer:"GRAPH",kind:"nodeRule",path:e,reason:{de:n,en:t},severity:"error"}),"issue"),VF={outcomes:[{id:mr,label:{de:"Gestartet",en:"Started"}}],validate:s((e,n)=>{let t=[],r=e;for(let i of K6)i in r&&t.push(nv(`nodes.${e.id}.${i}`,`[graph/retiredField] Start-Knoten "${e.id}": \`${i}\` gibt es nicht mehr \u2014 der Knotentyp deklariert seinen einen Ausgang \u201E${mr}" selbst.`,`[graph/retiredField] Start node "${e.id}": \`${i}\` no longer exists \u2014 the node type declares its one outcome "${mr}" itself.`));return Qt(n.nodes).some(i=>i.target===e.id)&&t.push(nv(`nodes.${e.id}`,`[eventTrigger/notStart] Knoten "${e.id}" ist ein Start-Knoten, hat aber eine eingehende Kante \u2014 nur der Start l\xF6st ihn aus, jeder Vorgang bliebe hier stehen.`,`[eventTrigger/notStart] Node "${e.id}" is a start node but has an incoming edge \u2014 only the start triggers it, every process would stop here.`)),e.next?.[mr]===void 0&&t.push(nv(`nodes.${e.id}.next.${mr}`,`[eventTrigger/unroutedStart] Start-Knoten "${e.id}" leitet \u201E${mr}" nirgendwohin.`,`[eventTrigger/unroutedStart] Start node "${e.id}" routes "${mr}" nowhere.`)),t},"validate")};var j6="submit",UF=[{id:j6,kind:"advance",label:{de:"Absenden",en:"Submit"},availableIn:["draft"]}];function GF(e){return e==="draft"}s(GF,"isWritableSmartFormState");var tv=["draft","committed"],nRe=tv.filter(e=>GF(e));async function zF(e,n,t){let r=await e.db.query("smart_form_instances").withIndex("by_applicationId_and_formNodeId",i=>i.eq("applicationId",n).eq("formNodeId",t)).take(2);return r.length>1&&F(`application ${n}: two form instances for node "${t}" (${r[0]._id}, ${r[1]._id}) \u2014 at most one may exist`),r[0]??null}s(zF,"getSmartFormInstance");var WF="form:fill",rv="request:collectPayment";var B6={key:WF,recipient:"external",title:{de:"Bewerbung ausf\xFCllen & absenden",en:"Complete & submit application"},unlocks:["submit"],advancesNode:!0},YF={key:"bearbeitung",label:te("In Bearbeitung","In progress"),scope:"node"},HF={[qR]:{label:te("In Bearbeitung","In progress"),tone:"neutral",phase:YF,external:en(te("Entwurf","Draft"),"neutral",te("Bewerbung fortsetzen","Continue application"),te("Sie haben die Bewerbung bereits begonnen. Schlie\xDFen Sie sie ab, um sie einzureichen.","You have already started the application. Complete it to submit it."),te("Bewerbung fortsetzen","Continue application"),"continue-form")},[Xu]:{label:te("Eingereicht","Submitted"),tone:"blue",phase:YF,external:en(te("Eingereicht","Submitted"),"blue",te("Ihre Bewerbung ist eingereicht","Your application has been submitted"),te("Ihre Bewerbung ist bei uns eingegangen. Wir melden uns mit den n\xE4chsten Schritten.","We have received your application. We will be in touch with the next steps."))}},JF={role:"user-action",effect:"side-effect",progressDefaults:HF,progressEvents:Mn(HF),actions:s(()=>UF,"actions"),workItemTemplates:s(()=>[B6],"workItemTemplates"),states:tv,currentState:s(async(e,n)=>{let t=await zF(e,n.applicationId,n.node.id);return t===null?"draft":t.state},"currentState"),inputs:s(e=>[{id:"smartForm",label:{de:"Formular",en:"Form"},type:"smartForm",optionSource:"offerSmartForms",required:e.adoptForm===void 0,inspector:"literal-only"}],"inputs"),outputs:s(e=>[{name:"admission",type:"admission",label:{de:"Anmeldung",en:"Application"},schema:[{key:"beneficiary",type:"personRef",label:{de:"Beschulte Person",en:"Student"}},{key:"signers",type:"personList",label:{de:"Unterzeichner",en:"Signers"}},...e.formExports??[]]}],"outputs"),notificationEvents:s(e=>vt(e)?[]:[{id:ef,label:{de:"Formular abgesendet",en:"Form submitted"},audience:"external",args:[{key:"applicationId",type:"string",required:!0}]}],"notificationEvents"),validate:s(e=>{let n=[],t=e.inputs?.smartForm,r=t?.kind==="literal"&&typeof t.value=="string"&&t.value.length>0,i=e.adoptForm!==void 0;return r&&i?n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.adoptForm`,reason:{de:`[form.adopt-xor-create] Form-Knoten "${e.id}" hat sowohl ein smartForm als auch adoptForm \u2014 genau eines ist erlaubt.`,en:`[form.adopt-xor-create] Form node "${e.id}" has both a smartForm and adoptForm \u2014 exactly one is allowed.`},severity:"error"}):!r&&!i&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.smartForm`,reason:{de:`[form.adopt-xor-create] Form-Knoten "${e.id}" braucht entweder ein smartForm (neu erzeugen) oder adoptForm (bestehende Instanz \xFCbernehmen).`,en:`[form.adopt-xor-create] Form node "${e.id}" needs either a smartForm (create new) or adoptForm (adopt an existing instance).`},severity:"error"}),n},"validate")};var QF={role:"system-action",effect:"side-effect",inputs:s(()=>[{id:On.target,label:{de:"Formular",en:"Form"},type:"admission",required:!0,inspector:"binding-only"},{id:On.flagKey,label:{de:"Merkmal im Formular",en:"Flag in the form"},type:"formFlag",required:!0,inspector:"literal-only",optionSource:"targetFormFlags"},{id:On.value,label:{de:"Setzen oder zur\xFCcknehmen",en:"Raise or lower"},type:"boolean",defaultValue:!0,inspector:"literal-only",enumOptions:[{value:"true",label:{de:"Setzen",en:"Raise"}},{value:"false",label:{de:"Zur\xFCcknehmen",en:"Lower"}}]}],"inputs"),notificationEvents:s(e=>[{id:"unlocked",label:{de:"Abschnitt freigeschaltet",en:"Section unlocked"},audience:"external",required:cO(e),args:[{key:"applicationId",type:"string",required:!0},{key:"sectionLabel",type:"localizedText",required:!0}]}],"notificationEvents"),validate:s(e=>{let n=[];e.inputs?.[On.flagKey]?.kind==="literal"&&xf(e)===null&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.${On.flagKey}`,reason:{de:`[setFlag/missingFlagKey] setFlag-Knoten "${e.id}" nennt kein Merkmal (Parameter \u201EMerkmal im Formular\u201C).`,en:`[setFlag/missingFlagKey] setFlag node "${e.id}" names no flag (parameter "Flag in the form").`},severity:"error"});let r=e.inputs?.[On.value];return r?.kind==="literal"&&typeof r.value!="boolean"&&n.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.${On.value}`,reason:{de:`[setFlag/valueType] setFlag-Knoten "${e.id}": \u201ESetzen oder zur\xFCcknehmen\u201C ist ein Ja/Nein-Wert (true/false), kein Text.`,en:`[setFlag/valueType] setFlag node "${e.id}": "Raise or lower" is a yes/no value (true/false), not text.`},severity:"error"}),n},"validate")};var V6="true",U6="false",iv=[{id:V6,label:{de:"Ja",en:"Yes"}},{id:U6,label:{de:"Nein",en:"No"}}];var ZF={role:"control",effect:"pure",cardinality:"1-to-N",outcomes:iv,validate:s((e,n,t)=>G6(e,n,t),"validate")};function G6(e,n,t){let r=s(o=>({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.condition`,reason:{de:`[if/condition] Knoten "${e.id}": ${o.de}`,en:`[if/condition] Node "${e.id}": ${o.en}`},severity:"error"}),"issue"),i=iv.filter(o=>e.next?.[o.id]===void 0).map(o=>({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.next.${o.id}`,reason:{de:`[if/unroutedOutcome] Knoten "${e.id}": Ausgang \u201E${o.label.de}\u201C (${o.id}) f\xFChrt nirgendwohin.`,en:`[if/unroutedOutcome] Node "${e.id}": Outcome "${o.label.en}" (${o.id}) leads nowhere.`},severity:"error"}));return typeof e.condition!="string"||e.condition.trim()===""?[...i,r({de:"Bedingung fehlt.",en:"The condition is missing."})]:[...i,...tp(e.condition,nI(n),t).map(r)]}s(G6,"ifNodeIssues");var ga="decision",z6=new Set(["decision","review"]),ERe=new Set([...z6,"governedDocument"]);var eL=[{id:"approved",label:{de:"Freigeben",en:"Approve"},semantic:"granted"},{id:"rejected",label:{de:"Ablehnen",en:"Reject"},semantic:"rejected"},{id:"waitlisted",label:{de:"Auf Warteliste",en:"Waitlist"},semantic:"waitlisted"}],XF={released:{label:te("Freigegeben","Released"),tone:"green",phase:{key:"freigabe",label:te("Freigabe","Release"),scope:"node"},external:en(te("Freigegeben","Released"),"green",te("Ihre Bewerbung wurde freigegeben","Your application has been released"),te("Wir haben Ihre Bewerbung freigegeben und melden uns mit den n\xE4chsten Schritten.","We have released your application and will be in touch with the next steps."))}},Bo={role:"user-action",effect:"side-effect",outcomes:eL,progressDefaults:XF,progressEvents:Mn(XF),notificationEvents:s(e=>(e.outcomes??[]).map(n=>({id:n.id,label:n.label,audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"comment",type:"string"}]})),"notificationEvents"),actions:s(e=>[...(e.outcomes??[]).map(n=>({id:n.id,kind:"advance",outcome:n.id,label:n.label,...Ii(n.semantic)?{semantic:n.semantic}:{}})),...DN(e)],"actions"),optionalActionKinds:["spawnTasks"],workItemTemplates:s(e=>[{key:ga,recipient:"internal",title:e.decisionAsTask?.title??{de:"Entscheidung",en:"Decision"},unlocks:(e.outcomes??[]).map(n=>n.id).filter(n=>typeof n=="string"&&n.length>0),gatesNode:!1,advancesNode:!0,dueInDays:e.decisionAsTask?.dueInDays}],"workItemTemplates"),taskDocuments:s((e,n)=>n===ga&&Array.isArray(e.reads)?e.reads.map(t=>({kind:"field",address:t})):[],"taskDocuments"),taskFormView:s((e,n)=>n===ga?e.formView:void 0,"taskFormView"),validate:ov};function ov(e,n,t){let r=[],i=e.outcomes??[];i.length===0&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes`,reason:{de:`[decision/missingOutcomes] Entscheidungs-Knoten "${e.id}" hat keine Outcomes \u2014 die Entscheidung w\xE4re niemals aufl\xF6sbar.`,en:`[decision/missingOutcomes] Decision node "${e.id}" has no outcomes \u2014 the decision could never be resolved.`},severity:"error"});let o=new Set(i.map(l=>l.id));for(let l of i){let d=l.label;(typeof d=="string"?d.trim().length>0:d!=null&&typeof d=="object"&&Object.values(d).some(p=>typeof p=="string"&&p.trim().length>0))||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes.${l.id}`,reason:{de:`[decision/outcomeMissingLabel] Outcome "${l.id}" von "${e.id}" hat keine Beschriftung \u2014 sie ist der Text des Knopfs im Cockpit.`,en:`[decision/outcomeMissingLabel] Outcome "${l.id}" of "${e.id}" has no label \u2014 it is the text of the button in the cockpit.`},severity:"error"});let u=l.semantic;u===void 0?r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes.${l.id}.semantic`,reason:{de:`[decision/outcomeSemanticMissing] Outcome "${l.id}" von "${e.id}" sagt nicht, was es bedeutet \u2014 eines von ${bt.join(", ")}.`,en:`[decision/outcomeSemanticMissing] Outcome "${l.id}" of "${e.id}" does not say what it means \u2014 one of ${bt.join(", ")}.`},severity:"error"}):Ii(u)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes.${l.id}.semantic`,reason:{de:`[decision/outcomeSemanticUnknown] Outcome "${l.id}" von "${e.id}" hat die Bedeutung "${String(u)}" \u2014 erlaubt: ${bt.join(", ")}.`,en:`[decision/outcomeSemanticUnknown] Outcome "${l.id}" of "${e.id}" has the meaning "${String(u)}" \u2014 allowed: ${bt.join(", ")}.`},severity:"error"})}for(let l of Object.keys(e.commentRequired??{}))o.has(l)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.commentRequired.${l}`,reason:{de:`[decision/commentRequiredUnknownOutcome] Unbekanntes Outcome "${l}" in commentRequired; erlaubt: ${[...o].join(", ")}`,en:`[decision/commentRequiredUnknownOutcome] Unknown outcome "${l}" in commentRequired; allowed: ${[...o].join(", ")}`},severity:"error"});let a=e.decisionAsTask?.title;return a!==void 0&&(a!==null&&typeof a=="object"&&Object.values(a).some(d=>typeof d=="string"&&d.length>0)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.decisionAsTask.title`,reason:{de:"[decision/decisionTaskMissingTitle] decisionAsTask.title ist gesetzt, aber leer \u2014 entweder einen nicht-leeren lokalisierten Text angeben oder das Feld weglassen (dann greift der Standardtitel).",en:"[decision/decisionTaskMissingTitle] decisionAsTask.title is set but empty \u2014 either give a non-empty localized text or omit the field (the default title then applies)."},severity:"error"})),r}s(ov,"validateDecisionNode");var sv=[{id:"promoted",label:{de:"Nachger\xFCckt",en:"Moved up"}},{id:"closed",label:{de:"Warteliste geschlossen",en:"Waiting list closed"}}],nL=[{id:"complete",label:{de:"Vollst\xE4ndig",en:"Complete"}},{id:"acceptedIncomplete",label:{de:"Ohne Nachreichung abgeschlossen",en:"Closed without the missing documents"}},{id:"rejected",label:{de:"Abgelehnt",en:"Rejected"}},{id:"absage",label:{de:"Zur\xFCckgezogen",en:"Withdrawn"}}];var av="promoted";var tL="promote",rL="Nachr\xFCcken";var lv={key:"warteliste",label:te("Warteliste","Waitlist"),scope:"global",track:"parked",waitlist:!0},iL={waitlisted:{label:te("Warteliste","Waitlisted"),tone:"amber",phase:lv,external:en(te("Warteliste","Waiting list"),"amber",te("Sie stehen auf der Warteliste","You are on the waiting list"),te("Ihre Bewerbung wurde auf die Warteliste gesetzt. Wir informieren Sie, sobald ein Platz frei wird.","Your application has been placed on the waiting list. We will let you know as soon as a place becomes available."))},promoted:{label:te("Nachger\xFCckt","Promoted"),tone:"green",phase:lv,external:en(te("Nachger\xFCckt","Moved up"),"green",te("Sie sind nachger\xFCckt","You have moved up"),te("Es ist ein Platz frei geworden \u2014 Ihre Bewerbung l\xE4uft weiter.","A place has become available \u2014 your application continues."))},closed:{label:te("Warteliste geschlossen","Waitlist closed"),tone:"red",phase:lv,external:en(te("Warteliste geschlossen","Waiting list closed"),"red",te("Die Warteliste wurde geschlossen","The waiting list has been closed"),te("Leider ist kein Platz mehr frei geworden.","Unfortunately no place has become available."))}},oL={outcomes:sv,inputs:s(()=>[{id:"waitlistOrder",label:{de:"Reihenfolge der Warteliste",en:"Waiting list order"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:Yt.map(e=>({value:e,label:pI[e]}))}],"inputs"),validate:s((e,n)=>{let t=ay(e);if(t===null)return[];let r=n.nodes.filter(o=>o.type==="waitlist"&&o.id!==e.id),i=n.nodes.indexOf(e);for(let o of r){if(n.nodes.indexOf(o)>i)continue;let a=ay(o);if(a!==null&&a.waitlistOrder!==t.waitlistOrder)return[{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs`,reason:{de:`[waitlist/policyConflict] Wartelisten "${o.id}" und "${e.id}" nennen verschiedene Reihenfolgen \u2014 eine Kohorte hat EINE Warteliste.`,en:`[waitlist/policyConflict] Waiting lists "${o.id}" and "${e.id}" state different orders \u2014 a cohort has ONE waiting list.`},severity:"error"}]}return[]},"validate"),pausesApplicationTasks:!0,progressDefaults:iL,progressEvents:Mn(iL),notificationEvents:s(()=>[{id:"placed",label:{de:"Auf die Warteliste gesetzt",en:"Placed on the waiting list"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"rank",type:"number"}]},{id:"promoted",label:{de:"Nachger\xFCckt",en:"Promoted from the waiting list"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"rank",type:"number"}]}],"notificationEvents"),actions:s(e=>(e.outcomes!==void 0&&e.outcomes.length>0?e.outcomes:sv).some(t=>t.id===av)?[{id:tL,kind:"advance",outcome:av,semantic:"other",label:{de:rL,en:"Promote from waitlist"},surface:kr,superUserOnly:!0,teamAssignable:!0}]:[],"actions")};var dv="complete",Rd="acceptedIncomplete",ym="rejected",W6="absage",sL="closeWithoutDocuments",aL="rejectAtCompleteness",lL="Ohne Nachreichung abschlie\xDFen",dL="Ablehnen",cL="awaitingDocuments",cv="documentsComplete",uv="closedWithoutDocuments",fv="rejected",pv="withdrawn",uL="requested",zRe={[dv]:{event:cv,status:"complete",endsRole:!0},[Rd]:{event:uv,status:"acceptedIncomplete",endsRole:!1},[ym]:{event:fv,status:"rejected",endsRole:!0},[W6]:{event:pv,status:"withdrawn",endsRole:!0}};var Id=s(()=>bl[0],"beneficiary"),mv=366;function Y6(e){let n=e.reads,t=vl(e).flatMap(({address:r})=>fn(r)&&!bl.includes(r.path)?[r]:[]);return[...Array.isArray(n)?n.filter(fn):[],...t]}s(Y6,"printedFields");function H6(e,n){let t=se(n);return e.nodes.filter(r=>r.type==="governedDocument"&&Y6(r).some(i=>se(i)===t))}s(H6,"documentsPrinting");function J6(e,n){if(!fn(n)||n.path!==Id())return!1;let t=e.nodes.find(r=>r.id===n.owner);return t!==void 0&&t.type==="form"&&!vt(t)}s(J6,"isCreatedFormBeneficiary");function qn(e,n,t){return{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${n}`,reason:t,severity:"error"}}s(qn,"issue");function Q6(e,n,t){let r=new Map(e.nodes.map(l=>[l.id,l])),i=n.next??{},o=new Set,a=[dv,Rd].flatMap(l=>{let d=i[l]?.to;return d===void 0?[]:[d]});for(;a.length>0;){let l=a.pop();if(o.has(l))continue;o.add(l);let d=r.get(l);if(d!==void 0&&!(d.type==="review"&&we(d.form)&&wr(d.form)&&d.form.owner===t)){if(d.type==="end"){if(So(d)==="approved")return!0;continue}for(let c of Object.values(d.next??{}))a.push(c.to)}}return!1}s(Q6,"reachesApprovedEndUnreviewed");var hv={key:"unterlagen",label:te("Unterlagen nachreichen","Outstanding documents"),scope:"node"},fL={[cL]:{label:te("Unterlagen nachreichen","Outstanding documents"),tone:"amber",phase:hv,external:en(te("Unterlagen fehlen","Documents missing"),"amber",te("Bitte reichen Sie die fehlenden Unterlagen nach","Please submit the missing documents"),te("Uns fehlen noch einige Angaben oder Unterlagen. Sie finden die Liste und die Frist in Ihren Aufgaben.","Some details or documents are still missing. You will find the list and the deadline in your tasks."))},[cv]:{label:te("Unterlagen vollst\xE4ndig","Documents complete"),tone:"green",phase:hv,external:en(te("Unterlagen vollst\xE4ndig","Documents complete"),"green",te("Ihre Unterlagen sind vollst\xE4ndig","Your documents are complete"),te("Alle angeforderten Unterlagen liegen uns vor. Vielen Dank.","We have received all the requested documents. Thank you."))},[uv]:{label:te("Ohne Nachreichung abgeschlossen","Closed without documents"),tone:"neutral",phase:hv,external:en(te("Abgeschlossen","Closed"),"neutral",te("Die Nachreichung ist abgeschlossen","The document request is closed"),te("Wir haben die Anforderung der Unterlagen abgeschlossen. Ihre Bewerbung l\xE4uft weiter.","We have closed the document request. Your application continues."))},[fv]:{label:te("Abgelehnt","Rejected"),tone:"red",phase:YO,external:en(te("Abgelehnt","Rejected"),"red",te("Leider k\xF6nnen wir Ihnen keinen Platz anbieten","Unfortunately we cannot offer you a place"),te("Wir bedauern, Ihnen mitteilen zu m\xFCssen, dass wir Ihre Bewerbung nicht ber\xFCcksichtigen konnten.","We regret to inform you that we were unable to accept your application."))},[pv]:{label:te("Zur\xFCckgezogen","Withdrawn"),tone:"red",phase:Ff,external:en(te("Zur\xFCckgezogen","Withdrawn"),"red",te("Sie haben Ihre Bewerbung zur\xFCckgezogen","You have withdrawn your application"),te("Ihre Bewerbung wird nicht weitergef\xFChrt.","Your application will not be continued."))}},pL={outcomes:nL,progressDefaults:fL,progressEvents:Mn(fL),notificationEvents:s(()=>[{id:uL,label:{de:"Unterlagen angefordert",en:"Documents requested"},audience:"external",required:!0,args:[{key:"applicationId",type:"string",required:!0},{key:"fieldLabels",type:"localizedText",required:!0},{key:"dueAt",type:"number",required:!0}]}],"notificationEvents"),actions:s(e=>{let n=s(r=>e.next?.[r]!==void 0,"wired"),t=[];return n(Rd)&&t.push({id:sL,kind:"advance",outcome:Rd,semantic:"other",label:{de:lL,en:"Close without documents"},surface:kr,superUserOnly:!0,confirm:{title:{de:"Unterlagen unvollst\xE4ndig",en:"Documents incomplete"},body:{de:"Es geht ohne die fehlenden Unterlagen weiter. Die Anfrage an die Familie wird geschlossen.",en:"The application continues without the missing documents. The request to the family is closed."},confirmLabel:{de:"Abschlie\xDFen",en:"Close"}}}),n(ym)&&t.push({id:aL,kind:"advance",outcome:ym,semantic:"rejected",label:{de:dL,en:"Reject application"},surface:kr,superUserOnly:!0,confirm:{title:{de:"Unterlagen unvollst\xE4ndig",en:"Documents incomplete"},body:{de:"Der Platz wird abgesagt und die Anfrage an die Familie geschlossen. Das l\xE4sst sich nicht r\xFCckg\xE4ngig machen.",en:"The application is rejected and the request to the family is closed. This cannot be undone."},confirmLabel:{de:"Ablehnen",en:"Reject"}}}),t},"actions"),inputs:s(()=>[{id:"person",label:{de:"Person (Gasth\xF6rer-Rolle)",en:"Person (guest role)"},type:"personRef",required:!1},{id:"guestRole",label:{de:"Gastrolle bis zur Nachreichung",en:"Guest role until submitted"},type:"roleKey",required:!1,inspector:"literal-only",optionSource:"tenantRoles"}],"inputs"),validate:s((e,n,t)=>{let r=[],i=`Vollst\xE4ndigkeitspr\xFCfung \u201E${e.label?.de??e.id}\u201C (${e.id})`,o=`Completeness check "${e.label?.en||e.id}" (${e.id})`,a=s(E=>Ve(n,E,"de"),"shown"),l=s(E=>Ve(n,E,"en"),"shownEn"),d=e.requires;if(!Array.isArray(d)||d.length===0)r.push(qn(e,"requires",{de:`[completenessCheck/missingRequires] ${i} nennt keine Felder \u2014 \`requires\` muss mindestens ein Feld eines Formulars enthalten ($node.<formular>.admission.<feld>).`,en:`[completenessCheck/missingRequires] ${o} names no fields \u2014 \`requires\` must contain at least one field of a form ($node.<form>.admission.<field>).`}));else{let E=new Set;for(let A of d){if(!we(A))continue;let I=se(A);if(E.has(I)){r.push(qn(e,"requires",{de:`[completenessCheck/duplicateField] Feld ${a(A)} steht doppelt in \`requires\`.`,en:`[completenessCheck/duplicateField] Field ${l(A)} appears twice in \`requires\`.`}));continue}if(E.add(I),!fn(A)){r.push(qn(e,"requires",{de:`[completenessCheck/unknownField] ${a(A)} ist kein Feld eines Formulars \u2014 \`requires\` nennt Felder ($node.<formular>.admission.<feld>).`,en:`[completenessCheck/unknownField] ${l(A)} is not a field of a form \u2014 \`requires\` names fields ($node.<form>.admission.<field>).`}));continue}let _=oi(t,A);if(_==null)continue;let T=Fs("requires",Ds(_));T==="computed"||T==="repeated"?r.push(qn(e,"requires",{de:`[completenessCheck/fieldNotRequestable] Feld ${a(A)} ist ${_.kind==="computed"?"berechnet":"ein Feld einer wiederholten Gruppe"} \u2014 die Familie kann es nicht nachreichen.`,en:`[completenessCheck/fieldNotRequestable] Field ${l(A)} is ${_.kind==="computed"?"computed":"a field of a repeated group"} \u2014 the family cannot submit it later.`})):T==="untranslated"&&r.push(qn(e,"requires",{de:`[completenessCheck/fieldNameUntranslated] Feld ${a(A)} (\u201E${Fi(_,"de")}") hat keinen englischen Namen (Feld oder Person/Abschnitt) \u2014 der Brief \u201EUnterlagen angefordert" nennt es in der Sprache der Familie.`,en:`[completenessCheck/fieldNameUntranslated] Field ${l(A)} ("${Fi(_,"de")}") has no English name (field or person/section) \u2014 the letter "Documents requested" names it in the family's language.`}))}}let c=e.deadline,u=typeof c=="object"&&c!==null?c:{},p="inDays"in u,m="until"in u;if(p===m)r.push(qn(e,"deadline",{de:`[completenessCheck/deadlineShape] Vollst\xE4ndigkeitspr\xFCfung "${e.id}" braucht genau eine Frist: \`{ inDays: n }\` (Tage ab Eintritt) oder \`{ until: "JJJJ-MM-TT" }\`.`,en:`[completenessCheck/deadlineShape] Completeness check "${e.id}" needs exactly one deadline: \`{ inDays: n }\` (days after entry) or \`{ until: "YYYY-MM-DD" }\`.`}));else if(p){let E=u.inDays;(typeof E!="number"||!Number.isInteger(E)||E<0||E>mv)&&r.push(qn(e,"deadline.inDays",{de:`[completenessCheck/deadlineDays] Frist "${String(E)}" ist keine ganze Zahl von 0 bis ${mv} Tagen.`,en:`[completenessCheck/deadlineDays] Deadline "${String(E)}" is not a whole number from 0 to ${mv} days.`}))}else typeof u.until!="string"||Qy(u.until)===null?r.push(qn(e,"deadline.until",{de:`[completenessCheck/deadlineDate] Frist "${String(u.until)}" ist kein g\xFCltiges Datum (JJJJ-MM-TT).`,en:`[completenessCheck/deadlineDate] Deadline "${String(u.until)}" is not a valid date (YYYY-MM-DD).`})):u.until<fP(Date.now())&&r.push({...qn(e,"deadline.until",{de:`[completenessCheck/deadlinePassed] Frist "${u.until}" liegt in der Vergangenheit \u2014 jede Anfrage bek\xE4me den Tag des Eintritts als Frist. Datum aktualisieren?`,en:`[completenessCheck/deadlinePassed] Deadline "${u.until}" is in the past \u2014 every request would get the day of entry as its deadline. Update the date?`}),severity:"warning"});if(Array.isArray(d)){let E=new Map(d.filter(fn).map(A=>[se(A),A]));for(let A of E.values())for(let I of H6(n,A))r.push(qn(e,"requires",{de:`[completenessCheck/requiresConsumedUpstream] Feld ${a(A)} flie\xDFt in das Dokument \u201E${I.label?.de??I.id}" (${I.id}) ein \u2014 nach dessen Ausstellung kann die Familie es nicht mehr nachreichen. Feld aus \`requires\` oder aus dem Dokument nehmen.`,en:`[completenessCheck/requiresConsumedUpstream] Field ${l(A)} flows into the document "${I.label?.en||I.id}" (${I.id}) \u2014 once it is issued, the family can no longer submit it later. Remove the field from \`requires\` or from the document.`}))}if(Array.isArray(d)&&t!==void 0){let E=d.filter(fn).filter(_=>{let T=oi(t,_);return T!=null&&rp(T)}),I=[...new Set(E.map(_=>_.owner))].filter(_=>Q6(n,e,_));if(I.length>0){let _=E.filter(T=>I.includes(T.owner));r.push({...qn(e,"next",{de:`[review/unreviewedAfterSupply] ${_.map(a).join(", ")} ist pr\xFCfpflichtig und wird hier nachgereicht, aber nach \u201Evollst\xE4ndig\u201C oder \u201Eohne Nachreichung\u201C f\xFChrt ein Weg ohne Pr\xFCfknoten dieses Formulars zur Aufnahme \u2014 niemand pr\xFCft das Nachgereichte. Dort einen Pr\xFCfknoten einf\xFCgen (z. B. \u201EWenn nichts zu pr\xFCfen ist: Durchreichen\u201C).`,en:`[review/unreviewedAfterSupply] ${_.map(l).join(", ")} requires review and is supplied here, but after "complete" or "accepted incomplete" a path without a review node of this form leads to admission \u2014 nobody reviews what was supplied. Insert a review node there (e.g. "When nothing is owed: pass through").`}),severity:"warning"})}}let y=e.inputs?.guestRole,k=y?.kind==="literal"?y.value:void 0,g=e.inputs?.person,v=g?.kind==="binding"?g.address:null;k!==void 0&&(typeof k!="string"||k.trim()===""?r.push(qn(e,"inputs.guestRole",{de:"[completenessCheck/guestRoleEmpty] `guestRole` ist leer \u2014 Rollenschl\xFCssel angeben oder das Feld weglassen.",en:"[completenessCheck/guestRoleEmpty] `guestRole` is empty \u2014 give a role key or omit the field."})):t?.roleKeys!==void 0&&!t.roleKeys.has(k)?r.push(qn(e,"inputs.guestRole",{de:`[completenessCheck/unknownRole] Rolle "${k}" existiert nicht im Rollenkatalog des Mandanten. Bekannte Rollen: ${[...t.roleKeys].sort().join(", ")}.`,en:`[completenessCheck/unknownRole] Role "${k}" does not exist in this school's role catalog. Known roles: ${[...t.roleKeys].sort().join(", ")}.`})):t?.assignableRoleKeys!==void 0&&!t.assignableRoleKeys.has(k)&&r.push(qn(e,"inputs.guestRole",{de:`[completenessCheck/nonLeafRole] Rolle "${k}" hat untergeordnete Rollen und ist nicht vergebbar.`,en:`[completenessCheck/nonLeafRole] Role "${k}" has sub-roles and cannot be assigned.`})),v===null&&r.push(qn(e,"inputs.person",{de:`[completenessCheck/guestRoleNeedsPerson] ${i} vergibt die Rolle "${String(k)}", aber der Eingang \u201Eperson" ist nicht gebunden (z. B. an $node.<formular>.${it}.${Id()}).`,en:`[completenessCheck/guestRoleNeedsPerson] ${o} assigns the role "${String(k)}", but the input "person" is not bound (e.g. to $node.<form>.${it}.${Id()}).`}))),we(v)&&!J6(n,v)&&r.push(qn(e,"inputs.person",{de:`[completenessCheck/personNotFormParty] Eingang \u201Eperson" ist an ${a(v)} gebunden \u2014 die Pr\xFCfung vergibt die Rolle der Person, f\xFCr die ein Formular abgeschickt wurde ($node.<anlegender Formularknoten>.${it}.${Id()}).`,en:`[completenessCheck/personNotFormParty] The input "person" is bound to ${l(v)} \u2014 the check assigns the role to the person a form was submitted for ($node.<creating form node>.${it}.${Id()}).`})),v!==null&&k===void 0&&r.push(qn(e,"inputs.person",{de:'[completenessCheck/personWithoutRole] Eingang \u201Eperson" ist gebunden, aber es wird keine Rolle vergeben \u2014 die Bindung wirkt nicht.',en:'[completenessCheck/personWithoutRole] The input "person" is bound, but no role is assigned \u2014 the binding has no effect.'}));for(let E of["complete","rejected"])e.next?.[E]===void 0&&r.push(qn(e,`next.${E}`,{de:`[completenessCheck/unroutedOutcome] Vollst\xE4ndigkeitspr\xFCfung "${e.id}" leitet den Ausgang "${E}" nirgendwohin.`,en:`[completenessCheck/unroutedOutcome] Completeness check "${e.id}" routes the outcome "${E}" nowhere.`}));return r},"validate")};var Z6=[{id:hI,label:{de:"Gepr\xFCft",en:"Reviewed"},semantic:"other"}],wm=s(e=>e,"asDecision"),mL={[gI]:{label:te("Eingereicht","Submitted"),tone:"blue",phase:{key:"pruefung",label:te("In Pr\xFCfung","In review"),scope:"node"},external:en(te("Eingereicht","Submitted"),"blue",te("Ihre Bewerbung wird gepr\xFCft","Your application is being reviewed"),te("Ihre Bewerbung ist bei uns eingegangen. Wir pr\xFCfen jetzt Ihre Unterlagen und melden uns, falls etwas fehlt.","We have received your application. We are now reviewing your documents and will get in touch if anything is missing."))}},hL={role:"user-action",effect:"side-effect",outcomes:Z6,progressDefaults:mL,progressEvents:Mn(mL),notificationEvents:s(e=>Bo.notificationEvents(wm(e)),"notificationEvents"),inputs:s(()=>[{id:Xt,label:{de:"Wenn nichts zu pr\xFCfen ist",en:"When nothing is owed"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:No.map(e=>({value:e,label:N_[e]}))}],"inputs"),actions:s(e=>[...Bo.actions(wm(e)).map(n=>n.kind==="advance"&&(e.outcomes??[]).length===1?{...n,label:{de:"Pr\xFCfung abschlie\xDFen",en:"Complete review"}}:n),{id:cy,kind:"internal",label:{de:"Feld abhaken",en:"Tick field"}}],"actions"),optionalActionKinds:Bo.optionalActionKinds,workItemTemplates:s(e=>Bo.workItemTemplates(wm(e)).map(n=>n.key===ga?{...n,title:e.decisionAsTask?.title??{de:"Angaben pr\xFCfen",en:"Review the application"},unlocks:[...n.unlocks,cy]}:n),"workItemTemplates"),taskDocuments:s(()=>[],"taskDocuments"),validate:s((e,n,t)=>{let r=ov(wm(e),n,t);for(let c of e.outcomes??[]){let u=c.semantic;typeof u!="string"||!mf.includes(u)||r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes`,reason:{de:`[review/rejectingOutcome] Pr\xFCf-Knoten "${e.id}" deklariert das Outcome "${c.id}" mit der Bedeutung "${String(u)}" \u2014 eine Pr\xFCfung lehnt nicht ab und setzt nicht auf die Warteliste; das ist die Entscheidung der Freigabe bzw. \u201EBewerbung ablehnen".`,en:`[review/rejectingOutcome] Review node "${e.id}" declares the outcome "${c.id}" meaning "${String(u)}" \u2014 a review neither rejects nor waitlists; that is the decision of the approval or "Reject application".`},severity:"error"})}let i={de:`\u201E${e.label?.de??e.id}\u201C (${e.id})`,en:`"${e.label?.en||e.id}" (${e.id})`},o=e.inputs?.[Xt],a=__(e);o!==void 0&&a===null&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.inputs.${Xt}`,reason:{de:`[review/unknownMode] Pr\xFCf-Knoten ${i.de}: \u201EWenn nichts zu pr\xFCfen ist\u201C muss ${No.join(" oder ")} als fester Wert sein.`,en:`[review/unknownMode] Review node ${i.en}: "When nothing is owed" must be the literal ${No.join(" or ")}.`},severity:"error"});let l=a==="advance",d=e.form;if(l&&d===void 0&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.form`,reason:{de:`[review/advanceNeedsForm] Pr\xFCf-Knoten ${i.de} reicht durch, wenn nichts zu pr\xFCfen ist, nennt aber kein Formular \u2014 er w\xFCrde immer durchreichen. Nenne das Formular, dessen pr\xFCfpflichtige Felder er pr\xFCft.`,en:`[review/advanceNeedsForm] Review node ${i.en} passes through when nothing is owed but names no form \u2014 it would always pass through. Name the form whose review-required fields it checks.`},severity:"error"}),l&&(e.outcomes??[]).length!==1&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.outcomes`,reason:{de:`[review/advanceOneOutcome] Pr\xFCf-Knoten ${i.de} reicht durch, hat aber ${(e.outcomes??[]).length} Outcomes \u2014 durchgereicht wird \xFCber genau eines.`,en:`[review/advanceOneOutcome] Review node ${i.en} passes through but has ${(e.outcomes??[]).length} outcomes \u2014 it passes through over exactly one.`},severity:"error"}),we(d)&&wr(d)){let c=t?.readinessFormFieldsByFormNode?.get(d.owner);c!==void 0&&![...c.values()].some(rp)&&r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.form`,reason:l?{de:`[review/nothingDeclared] Pr\xFCf-Knoten ${i.de} pr\xFCft ${se(d)}, aber dieses Formular erkl\xE4rt kein Feld als pr\xFCfpflichtig \u2014 der Schritt w\xFCrde jedes Mal durchreichen. Markiere die Felder im Formular als \u201EPr\xFCfpflichtig\u201C.`,en:`[review/nothingDeclared] Review node ${i.en} reviews ${se(d)}, but that form declares no field review-required \u2014 the step would pass through every time. Mark the fields "Review required" in the form.`}:{de:`[review/nothingDeclared] Pr\xFCf-Knoten ${i.de} pr\xFCft ${se(d)}, aber dieses Formular erkl\xE4rt kein Feld als pr\xFCfpflichtig \u2014 der Schritt wartet, ohne dass etwas abzuhaken ist. Markiere die Felder im Formular als \u201EPr\xFCfpflichtig\u201C.`,en:`[review/nothingDeclared] Review node ${i.en} reviews ${se(d)}, but that form declares no field review-required \u2014 the step waits with nothing to tick. Mark the fields "Review required" in the form.`},severity:l?"error":"warning"})}return r},"validate")};var gL=["awaitingAnswer","answered"];async function yL(e,n){return(await Pl(e,{applicationId:n.applicationId,nodeId:n.nodeId})).filter(r=>r.templateKey===n.templateKey).some(r=>r.isOpen)?"awaitingAnswer":"answered"}s(yL,"externalRequestState");var bL=[{id:Ns,label:{de:"Bezahlt",en:"Paid"}}],OIe=new Set(bL.map(e=>e.id));var X6=Ns,wL=[{id:X6,kind:"advance",outcome:Ns,semantic:"other",label:{de:"Zahlung eingegangen",en:"Payment received"},availableIn:["awaitingAnswer"]}],e3={id:My,kind:"advance",outcome:Ns,semantic:"other",label:{de:"Zahlung \xFCberspringen",en:"Skip payment"},surface:kr,superUserOnly:!0,confirm:{title:{de:"Zahlung \xFCberspringen",en:"Skip payment"},body:{de:"Die Geb\xFChr wird au\xDFerhalb von Plexus abgerechnet. Der Schritt wird ohne Zahlung abgeschlossen; es wird kein Betrag als bezahlt verbucht.",en:"The fee is billed outside Plexus. The step is completed without a payment; no amount is recorded as paid."},confirmLabel:{de:"\xDCberspringen",en:"Skip"}}},n3={id:My,kind:"advance",outcome:Ns,semantic:"other",label:{de:"Ohne Online-Zahlung abschlie\xDFen",en:"Close without online payment"},surface:kr,superUserOnly:!0,availableIn:["awaitingAnswer"],confirm:{title:{de:"Ohne Online-Zahlung abschlie\xDFen",en:"Close without online payment"},body:{de:"Die Familie hat nicht online \xFCber Plexus bezahlt. Der Schritt wird ohne Online-Zahlung abgeschlossen; eine offene Zahlungsseite wird geschlossen. Bitte den Grund angeben (z. B. bar bezahlt).",en:"The family did not pay online through Plexus. The step is completed without an online payment; an open payment page is closed. Please give the reason (e.g. paid in cash)."},confirmLabel:{de:"Abschlie\xDFen",en:"Complete"}},commentRequired:!0};function gv(e,n){let t=e.inputs?.[n];return t?.kind==="literal"?t.value:void 0}s(gv,"literalOf");function ya(e){let n=gv(e,Ht);return Tf(n)?n:null}s(ya,"settlementOrNull");function t3(e){let n=gv(e,Ci);return typeof n=="string"&&n.length>0?n:null}s(t3,"articleKeyOrNull");function r3(e){let n=gv(e,Jt);return typeof n=="string"&&n.length>0&&n===n.trim()?n:null}s(r3,"payeeKeyOrNull");var i3={id:Ci,label:{de:"Artikel",en:"Article"},type:"article",required:!0,inspector:"literal-only",optionSource:"programArticles"},o3={id:Ht,label:{de:"Abrechnung",en:"Settlement"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:[{value:"separate",label:{de:"Separat (Schule)",en:"Separately (school)"}},{value:"online",label:{de:"Online (Stripe)",en:"Online (Stripe)"}}]},s3={id:Di,label:{de:"Hinweis f\xFCr die Familie",en:"Note for the family"},type:"localizedText",required:!1,inspector:"literal-only"},a3={id:Jt,label:{de:"Zahlungsempf\xE4nger (Tr\xE4ger)",en:"Payee (legal entity)"},type:"legalEntity",required:!0,inspector:"literal-only",optionSource:"tenantTraeger"};function l3(e){return[i3,o3,...ya(e)==="online"?[a3]:[],s3]}s(l3,"collectPaymentInputs");var d3=["amount","currency","settlement"];function c3(e,n){if(ya(e)!=="online")return[];let t=r3(e);if(t===null)return[];let r=`nodes.${e.id}.inputs.${Jt}`,i=s(o=>({layer:"GRAPH",kind:"nodeRule",path:r,reason:o,severity:"error"}),"at");return n?.traeger!==void 0&&!n.traeger.has(t)?[i({de:`[collectPayment/unknownPayee] Zahlungsempf\xE4nger \u201E${t}" ist kein Tr\xE4ger dieses Mandanten \u2014 bekannt: ${[...n.traeger.keys()].join(", ")||"(keiner)"}.`,en:`[collectPayment/unknownPayee] Payee "${t}" is not a legal entity of this school \u2014 known: ${[...n.traeger.keys()].join(", ")||"(none)"}.`})]:n?.stripeReadyTraegerKeys!==void 0&&!n.stripeReadyTraegerKeys.has(t)?[i({de:`[collectPayment/onlineWithoutStripe] Abrechnung \u201Eonline" an \u201E${t}" setzt voraus, dass dieser Tr\xE4ger ein einsatzbereites Stripe-Konto hat (Administration \u2192 Integrationen \u2192 Stripe, Tr\xE4ger \u201E${t}") \u2014 sonst kann keine Familie bezahlen. Bis dahin \u201Eseparat" w\xE4hlen.`,en:`[collectPayment/onlineWithoutStripe] Settlement "online" to "${t}" requires this legal entity to have a ready Stripe account (Administration \u2192 Integrations \u2192 Stripe, legal entity "${t}") \u2014 otherwise no family can pay. Until then, choose "separate".`})]:[]}s(c3,"payeeIssues");var kL={awaitingPayment:{label:te("Zahlung ausstehend","Awaiting payment"),tone:"amber",phase:{key:"zahlung",label:te("Zahlung","Payment"),scope:"node"},external:en(te("Zahlung offen","Payment due"),"amber",te("Bitte begleichen Sie die Anmeldegeb\xFChr","Please pay the application fee"),te("Ihre Bewerbung l\xE4uft weiter, sobald die Zahlung bei uns eingegangen ist.","Your application continues as soon as we have received the payment."))}},vL={outputs:s(()=>[{name:eO,type:"object",label:{de:"Zahlung",en:"Payment"}}],"outputs"),role:"user-action",effect:"side-effect",inputs:s(e=>l3(e),"inputs"),outcomes:bL,progressDefaults:kL,progressEvents:Mn(kL),notificationEvents:s(e=>ya(e)!=="online"?[]:[{id:"requested",label:{de:"Zahlung angefordert",en:"Payment requested"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"amount",type:"number",required:!0}]}],"notificationEvents"),actions:s(e=>{let n=ya(e);return n==="online"?[...wL,n3]:n==="separate"?[e3]:[]},"actions"),states:gL,currentState:s((e,n)=>yL(e,{applicationId:n.applicationId,nodeId:n.node.id,templateKey:rv}),"currentState"),workItemTemplates:s(e=>{let n=e;return ya(n)!=="online"?[]:[{key:rv,recipient:"external",title:n.label,unlocks:wL.map(t=>t.id),advancesNode:!0}]},"workItemTemplates"),validate:s((e,n,t)=>{let r=[],i=s((d,c)=>r.push({layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${d}`,reason:c,severity:"error"}),"push");for(let d of d3)d in e&&i(d,{de:`[collectPayment/retiredField] \u201E${d}" steht nicht mehr am Zahlungsknoten \u2014 Betrag und W\xE4hrung kommen aus dem Artikel (Parameter \u201EArtikel"), die Abrechnung ist der Parameter \u201EAbrechnung" (inputs.settlement).`,en:`[collectPayment/retiredField] "${d}" is no longer on the payment node \u2014 amount and currency come from the article (parameter "Article"), and settlement is the parameter "Settlement" (inputs.settlement).`});r.push(...c3(e,t)),ya(e)===null&&i(`inputs.${Ht}`,{de:`[collectPayment/invalidSettlement] Abrechnung muss eine von ${Ps.join(", ")} sein (online = die Familie zahlt im Portal, separate = die Schule rechnet au\xDFerhalb von Plexus ab); erhalten ${JSON.stringify(e.inputs?.[Ht])}.`,en:`[collectPayment/invalidSettlement] Settlement must be one of ${Ps.join(", ")} (online = the family pays in the portal, separate = the school bills outside Plexus); received ${JSON.stringify(e.inputs?.[Ht])}.`});let o=e.inputs?.[Di];if(o?.kind==="literal"){let d=Ef(o.value);d!==null&&i(`inputs.${Di}`,{de:`[collectPayment/reasonText] Der Hinweis f\xFCr die Familie braucht einen Text auf Deutsch und auf Englisch (${d}).`,en:`[collectPayment/reasonText] The note for the family needs a text in German and in English (${d}).`})}let a=t3(e);if(a===null)return i(`inputs.${Ci}`,{de:'[collectPayment/missingArticle] Der Zahlungsknoten nennt keinen Artikel \u2014 unter \u201EParameter" einen einmaligen Artikel des Programms w\xE4hlen (Finanzen \u2192 Artikel).',en:'[collectPayment/missingArticle] The payment node names no article \u2014 under "Parameters" choose a one-time article of the program (Finance \u2192 Articles).'}),r;let l=`inputs.${Ci}`;return t?.billingItemKeys!==void 0&&!t.billingItemKeys.has(a)?(i(l,{de:`[collectPayment/unknownArticle] Artikel \u201E${a}" \u2014 kein Artikel dieses Mandanten tr\xE4gt diesen Schl\xFCssel.`,en:`[collectPayment/unknownArticle] Article "${a}" \u2014 no article of this school has this key.`}),r):(t?.oneTimeBillingItemKeys!==void 0&&!t.oneTimeBillingItemKeys.has(a)&&i(l,{de:`[collectPayment/articleNotOneTime] Artikel \u201E${a}" ist kein einmaliger Artikel \u2014 eine Geb\xFChr nimmt nur ${qy.join(", ")}.`,en:`[collectPayment/articleNotOneTime] Article "${a}" is not a one-time article \u2014 a fee only takes ${qy.join(", ")}.`}),t?.offerProgram===null?i(l,{de:"[collectPayment/articleOfferWithoutProgram] Das Angebot ist keinem Programm zugeordnet, also geh\xF6rt kein Artikel zu ihm; dem Angebot ein Programm geben.",en:"[collectPayment/articleOfferWithoutProgram] The offer is not assigned to a program, so no article belongs to it; give the offer a program."}):t?.offerProgram?.directBillingItemKeys!==void 0&&!t.offerProgram.directBillingItemKeys.has(a)&&i(l,{de:`[collectPayment/articleNotInProgram] Artikel \u201E${a}" ist dem Programm \u201E${t.offerProgram.nameDe}" des Angebots nicht direkt zugeordnet \u2014 unter Finanzen \u2192 Artikel zuordnen (ein Paket z\xE4hlt nicht: es kann den Artikel anders bepreisen).`,en:`[collectPayment/articleNotInProgram] Article "${a}" is not directly assigned to the offer's program "${t.offerProgram.nameDe}" \u2014 assign it under Finance \u2192 Articles (a package does not count: it can price the article differently).`}),r)},"validate")};function xL(e){return{de:`[governedDocument/localeFieldMissing] Die Vorlage "${e}" nennt kein Sprachfeld \u2014 ein Schreiben entsteht in genau einer Sprache. Ein Pflicht-Auswahlfeld mit den Optionen de/en unter den Parametern der Vorlage anlegen, es als localeField der Vorlage nennen und im Knoten an die Sprache des Benutzerkontos binden ($env.applicant.language); die Word-Datei h\xE4lt je Sprache einen Abschnitt <<#input.<feld>.de>> \u2026 <</input.<feld>.de>>.`,en:`[governedDocument/localeFieldMissing] The template "${e}" names no language field \u2014 a letter is written in exactly one language. Create a required choice field with the options de/en among the template's parameters, name it as the template's localeField and bind it in the node to the language of the user account ($env.applicant.language); the Word file holds one section per language <<#input.<field>.de>> \u2026 <</input.<field>.de>>.`}}s(xL,"localeFieldMissingText");var yv=new Set(["string","email","tel","number","date","boolean","enum","pricedItem"]),SL=/^[a-z][a-z0-9_]*$/;function AL(e,n){let t=[],r=e?.fields;if(!Array.isArray(r))return[{path:"",reason:{de:`[governedDocument/missingTemplateFields] Die Vorlage "${n}" deklariert keine Parameter \u2014 erwartet wird { fields } (die Platzhalter input.<schl\xFCssel>, die ein Knoten f\xFCllt).`,en:`[governedDocument/missingTemplateFields] The template "${n}" declares no parameters \u2014 expected { fields } (the placeholders input.<key> a node fills).`}}];let i=r,o=new Set;for(let a of i){if(typeof a?.key!="string"||!SL.test(a.key)||o.has(a.key)){t.push({path:`fields.${String(a?.key)}`,reason:{de:`[governedDocument/templateFieldKey] Feld "${String(a?.key)}" der Vorlage "${n}" ist ${o.has(a?.key)?"doppelt":"kein g\xFCltiger Schl\xFCssel"} \u2014 erlaubt sind eindeutige Kleinbuchstaben, Ziffern und _ (gedruckt als input.<schl\xFCssel>).`,en:`[governedDocument/templateFieldKey] Field "${String(a?.key)}" of the template "${n}" is ${o.has(a?.key)?"duplicated":"not a valid key"} \u2014 allowed are unique lower-case letters, digits and _ (printed as input.<key>).`}});continue}o.add(a.key);let l=`fields.${a.key}`;if(!_i(a.type)){t.push({path:l,reason:{de:`[governedDocument/unknownFieldType] Vorlage "${n}" typisiert das Feld "${a.key}" als "${String(a.type)}" \u2014 das geh\xF6rt nicht zum Wert-Vokabular der Plattform (${Os.join(", ")}).`,en:`[governedDocument/unknownFieldType] Template "${n}" types the field "${a.key}" as "${String(a.type)}" \u2014 that is not part of the platform's value vocabulary (${Os.join(", ")}).`}});continue}if(yv.has(a.type)||t.push({path:l,reason:{de:`[governedDocument/templateFieldType] Feld "${a.key}" der Vorlage "${n}" hat den Typ "${a.type}" \u2014 ein Brief druckt nur ${[...yv].join(", ")}.`,en:`[governedDocument/templateFieldType] Field "${a.key}" of the template "${n}" has the type "${a.type}" \u2014 a letter only prints ${[...yv].join(", ")}.`}}),a.type==="enum"&&Array.isArray(a.options)&&a.options.some(d=>!SL.test(String(d.value)))&&t.push({path:l,reason:{de:`[governedDocument/templateFieldKey] Auswahlfeld "${a.key}" der Vorlage "${n}" hat Optionen, die kein Platzhalter adressieren kann (${a.options.map(d=>d.value).join(", ")}) \u2014 Optionswerte sind Kleinbuchstaben, Ziffern und _ (gedruckt als input.${a.key}.<option>).`,en:`[governedDocument/templateFieldKey] Select field "${a.key}" of the template "${n}" has options no placeholder can address (${a.options.map(d=>d.value).join(", ")}) \u2014 option values are lower-case letters, digits and _ (printed as input.${a.key}.<option>).`}}),a.type==="enum"&&(!Array.isArray(a.options)||a.options.length===0)&&t.push({path:l,reason:{de:`[governedDocument/templateFieldOptions] Auswahlfeld "${a.key}" der Vorlage "${n}" nennt keine Optionen \u2014 ohne sie gibt es keine Abschnitte input.${a.key}.<option>.`,en:`[governedDocument/templateFieldOptions] Select field "${a.key}" of the template "${n}" names no options \u2014 without them there are no sections input.${a.key}.<option>.`}}),a.type==="pricedItem"){let d=i.find(c=>c.key===a.priceDate);(d===void 0||d.type!=="date")&&t.push({path:l,reason:{de:`[governedDocument/templateFieldPriceDate] Preisfeld "${a.key}" der Vorlage "${n}" nennt kein Preisdatum \u2014 priceDate muss ein Datumsfeld derselben Vorlage sein (welche Preisversion gilt); genannt: ${JSON.stringify(a.priceDate)}.`,en:`[governedDocument/templateFieldPriceDate] Price field "${a.key}" of the template "${n}" names no price date \u2014 priceDate must be a date field of the same template (which price version applies); named: ${JSON.stringify(a.priceDate)}.`}})}else a.priceDate!==void 0&&t.push({path:l,reason:{de:`[governedDocument/templateFieldPriceDate] Feld "${a.key}" setzt priceDate, ist aber kein Preisfeld (pricedItem).`,en:`[governedDocument/templateFieldPriceDate] Field "${a.key}" sets priceDate but is not a price field (pricedItem).`}});a.processSource==="countersignature"?t.push({path:l,reason:{de:`[governedDocument/countersignatureInTemplate] Feld "${a.key}" wird bei einer Gegenzeichnung gesetzt \u2014 ein Brief aus einer Vorlage wird nicht gegengezeichnet.`,en:`[governedDocument/countersignatureInTemplate] Field "${a.key}" is set at a countersignature \u2014 a letter from a template is not countersigned.`}}):a.processSource!==void 0&&!fp.includes(a.processSource)&&t.push({path:l,reason:{de:`[governedDocument/unknownProcessSource] Feld "${a.key}" nennt die unbekannte Vorgangsquelle "${String(a.processSource)}" \u2014 bekannt sind ${fp.join(", ")}.`,en:`[governedDocument/unknownProcessSource] Field "${a.key}" names the unknown case source "${String(a.processSource)}" \u2014 known are ${fp.join(", ")}.`}})}return t.push(...u3(e,n)),t}s(AL,"templateParameterIssues");function u3(e,n){if(e.localeField===void 0)return[{path:"localeField",reason:xL(n)}];let t=e.fields.find(i=>i.key===e.localeField),r=t===void 0?{de:"nennt kein Feld der Vorlage",en:"names no field of the template"}:t.type!=="enum"?{de:`ist ${t.type}, erwartet wird ein Auswahlfeld (enum)`,en:`is ${t.type}, a select field (enum) is expected`}:t.required!==!0?{de:"ist kein Pflichtfeld \u2014 ohne Sprache gibt es keine Variante",en:"is not a required field \u2014 without a language there is no variant"}:(t.options??[]).length===0?{de:"hat keine Optionen",en:"has no options"}:(t.options??[]).some(i=>!We.includes(i.value))?{de:`hat Optionen, die keine Sprache sind (erlaubt: ${We.join(", ")})`,en:`has options that are not a language (allowed: ${We.join(", ")})`}:null;return r===null?[]:[{path:"localeField",reason:{de:`[governedDocument/localeField] Das Sprachfeld "${e.localeField}" der Vorlage "${n}" ${r.de}.`,en:`[governedDocument/localeField] The language field "${e.localeField}" of the template "${n}" ${r.en}.`}}]}s(u3,"localeFieldIssues");function EL(e,n){if(n===null){delete e.templateStamp;return}e.templateStamp={fields:structuredClone(n.fields),...n.localeField===void 0?{}:{localeField:n.localeField}}}s(EL,"applyTemplateStamp");var wv=50;async function km(e,n){let t=await e.db.query("signing_returns").withIndex("by_signingRequestId",r=>r.eq("signingRequestId",n)).take(wv+1);return t.length>wv&&F(`signing_returns: Vorgang ${n} has more than ${wv} returns`),t}s(km,"returnsOf");var kv=50;async function bv(e,n){let t=await e.db.query("signing_return_documents").withIndex("by_signingReturnId_and_order",r=>r.eq("signingReturnId",n)).take(kv+1);return t.length>kv&&F(`signing_returns: return ${n} has more than ${kv} files`),t.length===0&&F(`[signing/noDocument] return ${n} carries no file`),t}s(bv,"returnDocumentsOf");async function TL(e,n){let t=await bv(e,n);return t.length!==1&&F(`[signing/severalDocuments] return ${n} carries ${t.length} files; this reader handles one`),t[0]}s(TL,"soleReturnDocumentOf");var bm=200,YIe=bm*20;async function f3(e,n){let t=await e.db.get(n);return t===null&&F(`[process] application ${n} not found`),t.redactedAt!==void 0}s(f3,"processRedacted");async function vv(e,n){await f3(e,n)&&le("CONFLICT",{de:"Die Daten dieser Bewerbung wurden gel\xF6scht.",en:"The data of this application has been deleted."})}s(vv,"assertProcessReadable");function p3(e){let n={_id:e._id,_creationTime:e._creationTime,owner:e.owner,key:e.key};return e.scope==="task"?{...n,scope:"task",result:{kind:"value",value:e.value},writtenByTaskId:e.writtenByTaskId}:{...n,scope:"node",result:e.result}}s(p3,"rowOf");async function $L(e,n,t){await vv(e,n);let r=await e.db.query("process_store_entries").withIndex("by_applicationId_and_scope_and_owner_and_key",i=>i.eq("applicationId",n).eq("scope",t.scope).eq("owner",t.owner).eq("key",t.key)).order("desc").take(bm+1);return r.length>bm&&F(`[process] application ${n} has more than ${bm} results of ${t.scope}.${t.owner}.${t.key}`),r.map(p3)}s($L,"storeHistory");async function m3(e,n,t){if(t.key===it){await vv(e,n);let i=await e.db.query("smart_form_instances").withIndex("by_applicationId_and_formNodeId",o=>o.eq("applicationId",n).eq("formNodeId",t.owner)).unique();return i===null||i.state!=="committed"?{state:"pending",reason:null}:{state:"present",result:{kind:"ref",ref:{kind:"form",formInstanceId:i._id}},row:null}}let[r]=await $L(e,n,{scope:"node",owner:t.owner,key:t.key});return r===void 0?{state:"pending",reason:null}:{state:"present",result:r.result,row:r}}s(m3,"nodeResultAt");async function vm(e,n){let t={scope:"node",owner:n.nodeId,key:n.key};return h3(await m3(e,n.applicationId,t),t,n.applicationId)}s(vm,"readOwnResult");function h3(e,n,t){return e.state!=="present"?{state:"pending"}:(e.result.kind!=="ref"&&F(`[process] ${se(n)} of application ${t} holds a value \u2014 this address holds a ref`),{state:"ref",ref:e.result.ref,row:e.row})}s(h3,"refOf");var xv={pending:"open",sent:"open",partially_signed:"open",completed:"terminal",declined:"terminal",voided:"terminal",expired:"terminal",failed:"terminal"},g3=Object.keys(xv),y3=g3.filter(e=>xv[e]==="open"),rOe=y3.filter(e=>e!=="pending");function RL(e){return xv[e]==="terminal"}s(RL,"isTerminalSigningStatus");var Ui=["docusign","insign"];var Od={docusign:"DocuSign",insign:"inSign",manual:"Auf Papier",simulated:"Simuliert (Testmodus)"};var k3=RL;function OL(e){return!k3(e.status)&&e.voidRequestedAt===void 0}s(OL,"holdsContract");async function PL(e,n){return await e.db.query("legal_entities").withIndex("by_partyId",t=>t.eq("partyId",n)).unique()}s(PL,"traegerLegalEntityOfParty");async function b3(e,n){return await e.db.query("organizations").withIndex("by_partyId",r=>r.eq("partyId",n)).first()!==null}s(b3,"isOrganizationParty");async function NL(e,n){return await PL(e,n)!==null?"traeger":await b3(e,n)?"organization":"person"}s(NL,"signerKindOf");async function _L(e,n){n.length===0&&F("signingSideOf: a Vorgang without signers asks nobody");for(let t of n)if(await v3(e,t.partyId)==="family")return"family";return"traeger"}s(_L,"signingSideOf");async function v3(e,n){return await NL(e,n)==="traeger"?"traeger":"family"}s(v3,"sideOfParty");var FOe=16*1024;var LOe=15*6e4;var MOe=10*6e4;var Sv={contractSnapshotId:Yn.restrict(w.id("contract_snapshots")),storageId:Yn.restrict(w.id("_storage")),sha256:w.string(),filename:w.string(),uploadedAt:w.number(),signers:w.array(w.object({partyId:Yn.history(w.id("parties")),role:w.string()}))},nPe=Jr({tenantId:Yn.tenant(w.id("tenants")),signingRequestDocumentId:Yn.belongsTo(w.id("signing_request_documents")),...Sv}).index("by_tenantId",["tenantId"]).index("by_signingRequestDocumentId",["signingRequestDocumentId"]).index("by_contractSnapshotId",["contractSnapshotId"]).index("by_storageId",["storageId"]);var sPe=w.object(Sv);var Av=200;async function S3(e,n,t,r){n.length>Av&&F(`${r} is carried by more than ${Av} signing requests`);let i=[],o=new Set;for(let l of n){if(o.has(l.signingRequestId))continue;o.add(l.signingRequestId);let d=await e.db.get(l.signingRequestId);d===null&&F(`signing_request_documents ${l._id} names a missing signing request ${l.signingRequestId}`),i.push(d)}let a=t==="asc"?1:-1;return i.sort((l,d)=>a*(l._creationTime-d._creationTime))}s(S3,"requestsOfMembers");async function CL(e,n,t="asc"){let r=await e.db.query("signing_request_documents").withIndex("by_contractSnapshotId",i=>i.eq("contractSnapshotId",n)).take(Av+1);return await S3(e,r,t,`revision ${n}`)}s(CL,"requestsOfSnapshot");var DL=100;async function A3(e,n){let t=await CL(e,n);t.length>DL&&F(`requestsBySideOf: revision ${n} has more than ${DL} Vorg\xE4nge`);let r={family:[],traeger:[]};for(let i of t.sort((o,a)=>o._creationTime-a._creationTime))r[await _L(e,i.signers)].push(i);return r}s(A3,"requestsBySideOf");async function Ev(e,n){return(await A3(e,n)).family}s(Ev,"familyRequestsOf");var Tv=100;async function E3(e,n){let t=await e;return t.length>Tv&&F(`contractChain: more than ${Tv} ${n}`),t}s(E3,"bounded");async function T3(e,n,t){let r=await vm(e,{applicationId:n,nodeId:t,key:Ts});return r.state==="pending"?null:(r.ref.kind!=="contract"&&F(`contractChain: $node.${t}.${Ts} of application ${n} is a ${r.ref.kind} ref \u2014 the contract chain writes a contract ref`),r.ref.contractId)}s(T3,"nodeContractRef");async function FL(e,n){return await E3(e.db.query("contract_snapshots").withIndex("by_contractId_and_revisionNumber",t=>t.eq("contractId",n)).take(Tv+1),`revisions on contract ${n}`)}s(FL,"snapshotsAsc");async function $v(e,n){let t=(await Ev(e,n)).filter(OL);return t.length>1&&F(`contractChain: revision ${n} has ${t.length} open family Vorg\xE4nge`),t[0]??null}s($v,"openFamilyRequest");async function $3(e,n){for(let t of await FL(e,n))if((await Ev(e,t._id)).some(r=>r.provider==="manual"))return"paper";return"provider"}s($3,"familyRoute");async function LL(e,n){for(let t of n)if(await $3(e,t)==="paper")return"paper";return"provider"}s(LL,"familyRouteOf");async function R3(e,n){let t=await TL(e,n._id),r=await e.db.system.get("_storage",t.storageId);return r===null&&F(`contractChain: return ${n._id} holds missing file ${t.storageId}`),{_id:n._id,_creationTime:n._creationTime,storageId:t.storageId,filename:t.filename,...r.contentType!==void 0?{mimeType:r.contentType}:{},round:n._id}}s(R3,"toReturn");function xm(e){async function n(a,l){return await T3(a,l,e.id)}s(n,"contractOrNull");async function t(a,l,d,c){let u=a.db.normalizeId("contract_snapshots",d),p=u===null?null:await a.db.get(u),m=await n(a,l);return(p===null||m===null||p.contractId!==m)&&F(`${c}: ${d} is no revision of node "${e.id}"'s contract ${m??"(none yet)"} \u2014 corrupt arc`),p}s(t,"snapshotOf");async function r(a,l){let d=await n(a,l);return d===null?null:(await FL(a,d)).at(-1)??null}return s(r,"newestSnapshot"),{reads:{kind:"contract",async returned(a,l,d){if(d.askedAbout===void 0){if(d.onUnpinned==="notReturned")return null;F(`returned(${d.where}): an ask of the contract chain is always pinned to its revision`)}let c=await t(a,l,d.askedAbout,`returned(${d.where})`),u=await $v(a,c._id);if(u===null)return null;let p=(await km(a,u._id)).filter(m=>m.review.status==="pending"&&m._id!==d.rejected);return p.length>1&&F(`returned(${d.where}): Vorgang ${u._id} has ${p.length} returns pending \u2014 one is checked at a time`),p[0]===void 0?null:await R3(a,p[0])},pinOf(a){return a.contractSnapshotId},returnPinOf(a){return a.signingReturnId}},contractOrNull:n,snapshotOf:t,newestSnapshot:r,contractsOf:{async contractsOf(a,l){let d=await n(a,l);return d===null?[]:[d]}}.contractsOf}}s(xm,"contractNodeReads");function Sm(e){return e.addedParts??[]}s(Sm,"addedPartsOf");var Rv=50;async function I3(e,n){let t=await e.db.query("contract_generation_runs").withIndex("by_packageRunId",r=>r.eq("packageRunId",n)).take(Rv+1);return t.length>Rv&&F(`groupRunsOf: generation group ${n} has more than ${Rv} runs`),t.length===0&&F(`groupRunsOf: generation group ${n} has no run`),t.sort((r,i)=>r._creationTime-i._creationTime)}s(I3,"groupRunsOf");async function ML(e,n){let t=await I3(e,n),r=t[0].packageRunId;if(r!==void 0){(t.some(l=>l.packageRunId!==r||l.partKey===void 0)||new Set(t.map(l=>l.partKey)).size!==t.length)&&F(`groupRunsInOrder: package group ${n} has inconsistent members`);let i=await e.db.get(r);i===null&&F(`groupRunsInOrder: package run ${n} is missing`);let o=await e.db.query("contract_package_parts").withIndex("by_packageRevisionId_and_position",l=>l.eq("packageRevisionId",i.packageRevisionId)).take(51),a=[...o.map(l=>l.partKey),...Sm(i).map(l=>l.partKey)];return(o.length>50||t.some(l=>!a.includes(l.partKey)))&&F(`groupRunsInOrder: package group ${n} names an unknown part`),t.sort((l,d)=>a.indexOf(l.partKey)-a.indexOf(d.partKey))}F(`Package run ${n} has no package reference.`)}s(ML,"groupRunsInOrder");function qL(e){return e.every(n=>n.status==="succeeded"&&n.contractId!==void 0&&n.contractSnapshotId!==void 0)}s(qL,"isCompleteGroup");var Iv=200;function O3(e){let n=e.generatorStamp?.parts;return n===void 0&&F(`groupChain: node "${e.id}" names no combined generator \u2014 only a combined generator keeps a group chain`),n.map(t=>t.partKey)}s(O3,"groupPartKeys");async function P3(e,n,t){let r=await e.db.query("contract_generation_runs").withIndex("by_applicationId_and_workflowNodeId",i=>i.eq("applicationId",n).eq("workflowNodeId",t)).take(Iv+1);return r.length>Iv&&F(`groupChain: more than ${Iv} generation runs on node ${t}`),r}s(P3,"nodeRuns");async function N3(e,n,t){let r=O3(t),i=new Set;for(let a of await P3(e,n,t.id))a.packageRunId===void 0&&F(`groupChain: run ${a._id} on the combined node "${t.id}" carries no generation group`),i.add(a.packageRunId);let o=[];for(let a of i){let l=await ML(e,a);if(!qL(l))continue;let d=await e.db.get(a);d===null&&F(`groupChain: generation group ${a} has no package run`);let c=new Set(Sm(d).map(p=>p.partKey)),u=[];for(let p of l){!r.includes(p.partKey)&&!c.has(p.partKey)&&F(`groupChain: run ${p._id} renders part "${p.partKey}", which node "${t.id}"'s pin does not declare and nobody added`);let m=await e.db.get(p.contractSnapshotId);m===null&&F(`groupChain: run ${p._id} names revision ${p.contractSnapshotId}, which is gone \u2014 a deleted draft lets its run go first`),u.push({run:p,snapshot:m})}o.push({packageRunId:a,startedAt:Math.min(...l.map(p=>p._creationTime)),members:u})}return o.sort((a,l)=>a.startedAt-l.startedAt)}s(N3,"groupRevisionRows");async function Ov(e,n,t){let r=await vm(e,{applicationId:n,nodeId:t,key:$s});return r.state==="pending"?[]:(r.ref.kind!=="contracts"&&F(`groupChain: $node.${t}.${$s} of application ${n} is a ${r.ref.kind} ref \u2014 the group chain writes a contracts ref`),[...r.ref.contracts])}s(Ov,"nodeGroupContracts");async function _3(e,n){let t=new Map;for(let{snapshot:r}of n.members){let i=await $v(e,r._id);i!==null&&t.set(i._id,i)}return t.size>1&&F(`groupChain: generation group ${n.packageRunId} is held by ${t.size} family Vorg\xE4nge \u2014 one Vorgang carries the group`),[...t.values()][0]??null}s(_3,"openGroupRequest");async function C3(e,n){let t=[];for(let i of await bv(e,n._id)){let o=await e.db.system.get("_storage",i.storageId);o===null&&F(`groupChain: return ${n._id} holds missing file ${i.storageId}`),t.push({contractSnapshotId:i.contractSnapshotId,storageId:i.storageId,filename:i.filename,...o.contentType!==void 0?{mimeType:o.contentType}:{}})}let r=t[0];return{_id:n._id,_creationTime:n._creationTime,storageId:r.storageId,filename:r.filename,...r.mimeType!==void 0?{mimeType:r.mimeType}:{},round:n._id,documents:t}}s(C3,"toGroupReturn");function KL(e){async function n(i,o,a,l){let d=(await N3(i,o,e)).find(c=>c.members[0]?.snapshot._id===a);return d===void 0&&F(`${l}: ${a} is no revision of node "${e.id}"'s generation groups \u2014 corrupt arc`),d}return s(n,"revisionRowOf"),{reads:{kind:"group",async returned(i,o,a){if(a.askedAbout===void 0){if(a.onUnpinned==="notReturned")return null;F(`returned(${a.where}): an ask of the group chain is always pinned to its lead revision`)}let l=await n(i,o,a.askedAbout,`returned(${a.where})`),d=await _3(i,l);if(d===null)return null;let c=(await km(i,d._id)).filter(u=>u.review.status==="pending"&&u._id!==a.rejected);return c.length>1&&F(`returned(${a.where}): Vorgang ${d._id} has ${c.length} returns pending \u2014 one is checked at a time`),c[0]===void 0?null:await C3(i,c[0])},pinOf(i){return i.contractSnapshotId},returnPinOf(i){return i.signingReturnId}},revisionRowOf:n,contractsOf:{async contractsOf(i,o){return(await Ov(i,o,e.id)).map(a=>a.contractId)}}.contractsOf}}s(KL,"groupNodeReads");async function D3(e,n){let t=n.lifecycle.kind==="draft"?void 0:n.lifecycle.kind;return{_id:n._id,_creationTime:n._creationTime,versionNumber:n.versionNumber,...t!==void 0?{status:t}:{},origin:n.origin.kind,storageId:n.storageId,...await bk(e,n.storageId),...n.filename!==void 0?{filename:n.filename}:{}}}s(D3,"toRevision");async function F3(e,n){let t=await D3(e,n);return{_id:t._id,_creationTime:t._creationTime,storageId:t.storageId,...t.filename!==void 0?{filename:t.filename}:{},...t.mimeType!==void 0?{mimeType:t.mimeType}:{},round:t.versionNumber}}s(F3,"toReturn");function jL(e){let n=hp(e);async function t(o,a){return await o.db.query("admission_documents").withIndex("by_applicationId_and_slotKey_and_versionNumber",l=>l.eq("applicationId",a).eq("slotKey",n)).collect()}return s(t,"contentRowsAsc"),{reads:{kind:"artifact",async returned(o,a,l){if(l.askedAbout===void 0){if(l.onUnpinned==="notReturned")return null;le("CONFLICT",{de:"Die offene Antwort-Aufgabe ist an keine Dokumentversion gebunden, daher l\xE4sst sich die unterschriebene Fassung nicht vom versandten Dokument unterscheiden. Stellen Sie das Dokument neu aus (Zur\xFCckziehen & neu ausstellen).",en:"The open response task is not bound to a document version, so the signed copy cannot be told apart from the document that was sent. Issue the document again (withdraw and reissue)."})}let d=await t(o,a),c=d[d.length-1];if(c===void 0||c._id===l.askedAbout||c.origin.kind!=="uploaded")return null;if(l.rejected!==void 0){let u=d.find(p=>p._id===l.rejected);if(u===void 0&&F(`returned(${l.where}): the handed-back scan ${l.rejected} is no version of slot "${n}"`),c.versionNumber<=u.versionNumber)return null}return await F3(o,c)},pinOf(o){return o.artifactVersionId},returnPinOf(o){return o.artifactVersionId}},contentRowsAsc:t,contractsOf:{async contractsOf(){return[]}}.contractsOf}}s(jL,"artifactNodeReads");function Am(e){return e.production==="none"&&F(`documentChainKind: node "${e.id}" has production 'none' \u2014 it keeps no document`),e.production!=="resolver"?"artifact":e.generatorStamp?.parts!==void 0?"group":"contract"}s(Am,"documentChainKind");function BL(e){switch(Am(e)){case"contract":return xm(e).reads;case"group":return KL(e).reads;case"artifact":return jL(e).reads}}s(BL,"documentReadsFor");var L3={de:"Haben Sie die Vertragsbedingungen gelesen und verstanden?",en:"Have you read and understood the contract terms?"};function Pd(e){let n=e.responseStrategy;return typeof n=="string"&&n in ci?ci[n].producesResponseArtifact:!1}s(Pd,"returnsSignedCopy");function M3(e){return Pd(e)&&e.confirmContractTerms!==!1}s(M3,"asksContractTerms");function VL(e){return M3(e)?{title:e.contractTermsQuestionText??L3,body:{de:"Die unterschriebene Fassung wird erst nach Ihrer Best\xE4tigung hochgeladen. Die Best\xE4tigung wird mit Zeitpunkt und Person festgehalten.",en:"The signed copy is uploaded only after you confirm. The confirmation is recorded with time and person."},confirmLabel:{de:"OK",en:"OK"}}:null}s(VL,"contractTermsConfirm");async function q3(e,n,t){if(t.revisesWorkItemId===void 0)return;let r=await e.db.get(t.revisesWorkItemId),i=r===null?null:cw(r),o=i?.context,a=o?.kind==="admission"?n.returnPinOf(o):void 0;return(i===null||o===void 0||o.kind!=="admission"||i.templateKey!==Kr||i.status!=="done"||i.outcome!=="rejected"||a===void 0)&&F(`rejectedReturnOfAsk: ask ${t._id} revises ${t.revisesWorkItemId}, which is not a rejected, pinned ${Kr} row`),a}s(q3,"rejectedReturnOfAsk");async function UL(e,n){return await n.chain.returned(e,n.applicationId,{askedAbout:n.chain.pinOf(n.ask),rejected:await q3(e,n.chain,n.ask),onUnpinned:n.onUnpinned,where:n.where})}s(UL,"returnedCopyOfAsk");var Pv=new Set([...Iw,qr,$o,Kr,ut]),YL={id:Vn,type:"contractGenerator",label:{de:"Vertragsgenerator",en:"Contract generator"},required:!0,inspector:"literal-only",optionSource:"tenantGenerators"},HL={id:ho,type:"documentTemplate",label:{de:"Dokumentvorlage",en:"Document template"},required:!0,inspector:"literal-only",optionSource:"tenantDocumentTemplates"};function K3(e){let n=[],t=[{slot:YL,production:"resolver",de:{a:"einen",the:"der",it:"ihn"}},{slot:HL,production:"template",de:{a:"eine",the:"die",it:"sie"}}];for(let{slot:r,production:i,de:o}of t){let a=e.inputs?.[r.id];if(a===void 0||a.kind==="unset")continue;let l=`inputs.${r.id}`;if(e.production!==i){n.push(Re(e,l,{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production '${e.production}', nennt aber ${o.a} ${r.label.de} \u2014 nur production '${i}' verwendet sie.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production '${e.production}' but names a ${r.label.en.toLowerCase()} \u2014 only production '${i}' uses it.`}));continue}if(a.kind==="binding"){n.push(Re(e,l,{de:`[governedDocument/referenceNotLiteral] Knoten "${e.id}": ${o.the} ${r.label.de} ist ein fester Wert des Knotens, keine Bindung \u2014 w\xE4hlen Sie ${o.it} aus.`,en:`[governedDocument/referenceNotLiteral] Node "${e.id}": the ${r.label.en.toLowerCase()} is a fixed value of the node, not a binding \u2014 choose it from the list.`}));continue}if(a.kind!=="literal")continue;let d=xl(a.value,{type:r.type});d!==null&&n.push(Re(e,l,{de:`[governedDocument/referenceShape] Knoten "${e.id}": ${d}.`,en:`[governedDocument/referenceShape] Node "${e.id}": ${d}.`}))}return n}s(K3,"referenceInputIssues");var j3={id:di,type:"number",label:{de:"Antwortfrist (Tage)",en:"Answer within (days)"},inspector:"literal-only"},B3={id:_t,type:"legalEntity",label:e_,required:!0,inspector:"literal-only",optionSource:"tenantTraeger"};function V3(e,n){let t=`inputs.${_t}`,r=e.inputs?.[_t];if(r!==void 0&&r.kind==="binding")return[Re(e,t,{de:`[governedDocument/traegerNotLiteral] Knoten "${e.id}": der Tr\xE4ger ist ein fester Wert des Knotens, keine Bindung \u2014 w\xE4hlen Sie ihn aus.`,en:`[governedDocument/traegerNotLiteral] Node "${e.id}": the legal entity is a fixed value of the node, not a binding \u2014 choose it from the list.`})];let i=Xs(e),o=n?.resolverPrintsTraegerAddress?.get(e.id)??new Set,a=[];for(let l of new Set([...i===null?[]:[i],...o])){let d=n?.traeger?.get(l);n?.traeger!==void 0&&d===void 0?a.push(Re(e,t,{de:`[governedDocument/unknownTraeger] Knoten "${e.id}" nennt den Tr\xE4ger "${l}", den es in diesem Mandanten nicht gibt \u2014 bekannt: ${[...n.traeger.keys()].join(", ")||"(keiner)"}.`,en:`[governedDocument/unknownTraeger] Node "${e.id}" names the legal entity "${l}", which does not exist in this school \u2014 known: ${[...n.traeger.keys()].join(", ")||"(none)"}.`})):d!==void 0&&!d.hasAddress&&o.has(l)&&a.push(Re(e,t,{de:`[governedDocument/traegerAddressMissing] Die Vorlage des Generators an Knoten "${e.id}" druckt die Anschrift des Tr\xE4gers (${ap.address}), aber "${l}" hat keine \u2014 in der Konfiguration des Mandanten nachtragen (foundation.legalEntities[].address).`,en:`[governedDocument/traegerAddressMissing] The generator template on node "${e.id}" prints the legal entity's address (${ap.address}), but "${l}" has none \u2014 add it in the school's configuration (foundation.legalEntities[].address).`}))}return a}s(V3,"traegerIssues");function Tm(e){if(e.production==="template"){let t=e.templateStamp?.fields;return Array.isArray(t)?t:[]}if(e.production!=="resolver")return[];let n=e.generatorStamp?.inputSchema?.fields;return Array.isArray(n)?n.map(t=>{let{label:r}=t;return r===void 0?{...t,label:{de:t.key,en:t.key}}:($i(r)||F(`governedDocument "${e.id}": the stamped generator parameter "${t.key}" has no { de, en } label (${JSON.stringify(r)}) \u2014 rebuild local fixtures or obtain a reviewed repair of this retained workflow stamp.`),{...t,label:r})}):[]}s(Tm,"generatorFields");function U3(e,n){return e.inputs?.[n]?.kind==="cockpit"}s(U3,"deferredToCockpit");function G3(e){return _i(e.type)?e.type:void 0}s(G3,"resolverSlotType");function z3(e){if(e.confirmBeforeIssue!==!0||e.approval!=="none")return null;let n=Kl(e);return{confirm:{title:{de:`\u201E${n.de}\u201C jetzt senden?`,en:`Send "${n.en}" now?`},body:{de:"Das Dokument wird danach f\xFCr die Familie sichtbar.",en:"The family will be able to see the document afterwards."},confirmLabel:{de:"Senden",en:"Send"}}}}s(z3,"issueConfirmation");function Re(e,n,t){return{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${n}`,reason:t,severity:"error"}}s(Re,"issue");function Em(e){return up.includes(e.production)&&Po.includes(e.approval)&&pp.includes(e.responseStrategy)}s(Em,"hasValidModes");async function Nv(e,n){let t=await Pl(e,{applicationId:n.applicationId,nodeId:n.node.id});if(t.length===0)return"pending";let r=t.filter(l=>l.isOpen&&l.kind==="admission"),i=r.filter(l=>l.templateKey!==void 0&&Iw.has(l.templateKey));if(i.length>0)return i.every(l=>l.status==="blocked")?"producingHeld":"producing";let o=r.find(l=>l.templateKey===qr);if(o!==void 0)return o.status==="blocked"?"deferred":"awaitingApproval";if(r.some(l=>l.templateKey===ut))return"signatureStalled";let a=r.find(l=>l.templateKey===$o);if(a!==void 0){if(Bi(n.node).issuesBy==="provider"){let d=Am(n.node)==="group"?(await Ov(e,n.applicationId,n.node.id)).map(c=>c.contractId):[await xm(n.node).contractOrNull(e,n.applicationId)].flatMap(c=>c===null?[]:[c]);if(d.length===0&&F(`governedDocCurrentState: eSignature node "${n.node.id}" has an open ask but no contract`),await LL(e,d)==="provider")return"awaitingSignature"}return Bi(n.node).producesResponseArtifact?await UL(e,{chain:BL(n.node),applicationId:n.applicationId,ask:a,onUnpinned:"notReturned",where:`governedDocCurrentState(node "${n.node.id}")`})===null?"awaitingResponse":"responseReturned":"awaitingResponse"}return r.some(l=>l.templateKey===Kr)?"responseInCheck":"done"}s(Nv,"governedDocCurrentState");function GL(e){return e.production!=="none"&&Am(e)!=="artifact"}s(GL,"keepsDocumentInContractDomain");function W3(e,n){let t=e.inputs?.[n.key];if(t?.kind!=="binding")return[];let r=t.address;if(!we(r)||r.scope!=="env"||!Wt(r.key))return[];let i=mo(r.key);if(n.type!==i.type)return[Re(e,`inputs.${n.key}`,{de:`[governedDocument/envNotCovered] Feld "${n.key}" ist ${n.type}, die Umgebungsvariable \u201E${i.label.de}\u201C (${se(r)}) liefert ${i.type}.`,en:`[governedDocument/envNotCovered] Field "${n.key}" is ${n.type}, the environment variable "${i.label.en}" (${se(r)}) supplies ${i.type}.`})];let o=new Set((n.options??[]).map(l=>l.value)),a=(i.enumOptions??[]).filter(l=>!o.has(l.value));return a.length===0?[]:[Re(e,`inputs.${n.key}`,{de:`[governedDocument/envNotCovered] Feld "${n.key}" kennt ${a.map(l=>`\u201E${l.label.de}\u201C (${l.value})`).join(", ")} nicht \u2014 die Umgebungsvariable \u201E${i.label.de}\u201C kann diese Werte liefern. Jeder Wert braucht eine Option.`,en:`[governedDocument/envNotCovered] Field "${n.key}" does not know ${a.map(l=>`"${l.label.en}" (${l.value})`).join(", ")} \u2014 the environment variable "${i.label.en}" can supply these values. Every value needs an option.`})]}s(W3,"envCoverageIssues");function JL(e,n){let t=[];for(let r of Tm(e)){if(r.type==="party"||r.type==="personList")continue;if(t.push(...W3(e,r)),r.processSource!==void 0){let a=e.inputs?.[r.key],l=a?.kind==="binding"?{de:`eine Bindung an ${we(a.address)?se(a.address):JSON.stringify(a.address)}`,en:`a binding to ${we(a.address)?se(a.address):JSON.stringify(a.address)}`}:a?.kind==="literal"?{de:"ein fester Wert",en:"a fixed value"}:U3(e,r.key)?{de:"eine Erg\xE4nzung im Cockpit",en:"a completion in the cockpit"}:null;l!==null&&t.push({layer:"GRAPH",kind:"contractGap",path:`nodes.${e.id}.inputs.${r.key}`,reason:{de:`[governedDocument/processSourceConflict] "${r.label.de}" wird vom Vorgang selbst gef\xFCllt (${r.processSource}), daneben steht ${l.de}. Eine der beiden Quellen bliebe wirkungslos \u2014 entferne die Verdrahtung.`,en:`[governedDocument/processSourceConflict] "${r.label.en}" is filled by the case itself (${r.processSource}), and ${l.en} is set as well. One of the two sources would have no effect \u2014 remove the wiring.`},severity:"error"});continue}if(r.required!==!0)continue;let i=e.inputs?.[r.key];i?.kind==="binding"||i?.kind==="literal"||i?.kind==="cockpit"||r.defaultValue!==void 0||t.push({layer:"GRAPH",kind:"contractGap",path:`nodes.${e.id}.inputs.${r.key}`,reason:{de:`[governedDocument/unsourcedRequiredField] Pflichtfeld "${r.label.de}" des Generators ${n.de} hat keine Quelle \u2014 binde es an ein Formular-Export-Feld, setze einen festen Wert oder lass es ausdr\xFCcklich im Cockpit erg\xE4nzen.`,en:`[governedDocument/unsourcedRequiredField] Required field "${r.label.en}" of the generator ${n.en} has no source \u2014 bind it to a form export field, set a fixed value or leave it explicitly to the cockpit.`},severity:"error"})}return t}s(JL,"fieldSourceIssues");function Y3(e){let n=pr(e)??"\u2014";if(e.templateStamp===void 0)return[];let t=AL(e.templateStamp,n).map(({path:r,reason:i})=>Re(e,r===""?"templateStamp":`templateStamp.${r}`,i));return t.push(...JL(e,{de:`Vorlage "${n}"`,en:`template "${n}"`})),t}s(Y3,"templateIssues");function H3(e,n){return(n?.resolverDocumentAnchors?.get(e.id)??[]).flatMap(t=>{if(t.documentAnchors===null)return[Re(e,"resolver",{de:`[governedDocument/eSignatureAnchorMissing] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben, aber die Vorlage des Generators "${t.pin}" wurde nie auf Unterschriftsanker gelesen \u2014 Vorlage neu hochladen und den Generator neu versiegeln.`,en:`[governedDocument/eSignatureAnchorMissing] Node "${e.id}" is signed electronically, but the generator template "${t.pin}" was never read for signature anchors \u2014 upload the template again and seal the generator again.`})];let r=t.signerAnchors.filter(i=>!t.documentAnchors.has(i));return r.length===0?[]:[Re(e,"resolver",{de:`[governedDocument/eSignatureAnchorMissing] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben, aber die Vorlage von "${t.pin}" tr\xE4gt keinen Anker f\xFCr ${r.map(i=>`/unterschrift:${i}/`).join(", ")} \u2014 der Anbieter f\xE4nde f\xFCr diese Personen kein Unterschriftsfeld.`,en:`[governedDocument/eSignatureAnchorMissing] Node "${e.id}" is signed electronically, but the template of "${t.pin}" has no anchor for ${r.map(i=>`/unterschrift:${i}/`).join(", ")} \u2014 the provider would find no signature field for these people.`})]})}s(H3,"eSignatureAnchorIssues");function J3(e,n){return n===void 0||n.sendable?[]:Bi(e).issuesBy!=="provider"?[]:[Re(e,"responseStrategy",{de:`[signing/noActiveProvider] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben, aber die Schule kann nicht senden: ${n.reason.de}`,en:`[signing/noActiveProvider] Node "${e.id}" is signed electronically, but the school cannot send: ${n.reason.en}`})]}s(J3,"eSignatureProviderIssues");var zL={key:"dokument",label:te("Dokument","Document"),scope:"node"},WL={producing:{label:te("Dokument in Vorbereitung","Document in preparation"),tone:"blue",phase:zL,external:en(te("In Vorbereitung","In preparation"),"blue",te("Ihr Dokument wird vorbereitet","Your document is being prepared"),te("Die Schule erstellt Ihr Dokument. Sie erhalten es in K\xFCrze im Portal.","The school is preparing your document. You will receive it in the portal shortly."))},issued:{label:te("Dokument bereitgestellt","Document issued"),tone:"blue",phase:zL,external:en(te("Dokument bereit","Document ready"),"amber",te("Ihr Dokument liegt bereit","Your document is ready"),te("Bitte beantworten Sie das Dokument innerhalb der Frist. Sie finden es in Ihren Aufgaben.","Please respond to the document within the deadline. You will find it in your tasks."),te("Dokument beantworten","Respond to the document"))}},QL={role:"user-action",effect:"side-effect",processHoldTemplate:s(()=>To,"processHoldTemplate"),progressDefaults:WL,progressEvents:Mn(WL),notificationEvents:s(e=>[{id:"issued",label:{de:"Dokument bereitgestellt",en:"Document issued"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"documentTitle",type:"localizedText",required:!0},{key:"dueInDays",type:"number"}]},{id:"responded",label:{de:"Antwort eingegangen",en:"Response received"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"documentTitle",type:"localizedText",required:!0}]},{id:"responseRejected",label:{de:"R\xFCcklauf zur\xFCckgegeben",en:"Returned copy handed back"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"documentTitle",type:"localizedText",required:!0},{key:"reason",type:"string",required:!0}]}],"notificationEvents"),strictActionCoverage:!0,actions:s(e=>{if(!Em(e))return[];let n=Bi(e),t=[],r=n.producesResponseArtifact?["awaitingResponse","responseReturned"]:["awaitingResponse"],i=n.issuesBy==="provider"?["awaitingSignature","signatureStalled",...r]:r,o=n.checksReturn?[...i,"responseInCheck"]:i;return e.production!=="none"&&(t.push({id:Pw(e),kind:"internal",surface:ea,label:e.approval==="release"?{de:"Freigabe anfordern",en:"Request approval"}:{de:"Bereitstellen",en:"Issue document"},availableIn:["producing","producingHeld"],...z3(e)??{}}),t.push({id:i_,kind:"internal",surface:ea,label:{de:"Korrigieren",en:"Correct"},availableIn:o,superUserOnly:!0},{id:o_,kind:"internal",surface:ea,label:{de:"Zur\xFCckziehen & neu ausstellen",en:"Rescind & re-issue"},availableIn:o,superUserOnly:!0})),t.push(n.checksReturn?{id:lp,kind:"internal",label:e.responseLabels?.accept??n.defaultLabels.accept,availableIn:[r[r.length-1]],external:{emphasis:"primary",event:"documentReturned"}}:{id:n.acceptOutcomeId,kind:"advance",outcome:n.acceptOutcomeId,semantic:n.outcomeSemantics.accept,label:e.responseLabels?.accept??n.defaultLabels.accept,availableIn:[r[r.length-1]],external:{emphasis:"primary",event:"userTaskResolved"}},{id:n.declineOutcomeId,kind:"advance",outcome:n.declineOutcomeId,semantic:n.outcomeSemantics.decline,label:e.responseLabels?.decline??n.defaultLabels.decline,availableIn:i,external:{emphasis:"decline",event:"userTaskResolved"}}),n.producesResponseArtifact&&t.push({id:dp,kind:"internal",label:{de:"\xC4nderung anfordern",en:"Request a change"},availableIn:i,external:{emphasis:"secondary",event:"documentChangeRequested"}}),n.issuesBy==="provider"&&t.push({id:cp,kind:"internal",surface:ea,label:{de:"Erneut senden",en:"Send again"},availableIn:["signatureStalled"]},{id:Ro,kind:"internal",surface:ea,label:{de:"Auf Papier umstellen",en:"Switch to paper"},availableIn:["signatureStalled"]}),t},"actions"),states:s_,currentState:Nv,workItemTemplates:s(e=>{let n=e;return Em(n)?Nw(n):[]},"workItemTemplates"),taskDocuments:s((e,n)=>{let t=e;if(!Em(t)||t.production==="none")return[];let r=Nw(t).find(i=>i.key===n);return r===void 0||r.recipient!=="internal"?[]:[{kind:"artifact",key:hp(t)}]},"taskDocuments"),inputs:s(e=>[...e.production==="resolver"?[YL,B3]:[],...e.production==="template"?[HL]:[],j3,...Tm(e).filter(n=>n.type!=="party"&&n.type!=="personList").flatMap(n=>{let t=G3(n);return t===void 0?[]:[{field:n,type:t}]}).map(({field:n,type:t})=>({id:n.key,type:t,label:n.label,required:n.required===!0&&n.processSource===void 0,...n.processSource===void 0?{deferrable:!0}:{},...n.defaultValue!==void 0&&(typeof n.defaultValue=="string"||typeof n.defaultValue=="number"||typeof n.defaultValue=="boolean"||n.defaultValue===null||t==="pricedItem"&&Oi(n.defaultValue))?{defaultValue:n.defaultValue}:{},...n.options!==void 0?{enumOptions:n.options}:{}}))],"inputs"),outputs:s(e=>e.production==="none"?[]:[{name:wl,type:"documentRef",label:{de:"Dokument",en:"Document"}}],"outputs"),refuseBlocksTarget:s((e,n)=>{if(n===$o||n===Ml||n===Kr||n===ut){let t=n===$o?{de:"die Antwort-Aufgabe geh\xF6rt dem Empf\xE4nger",en:"the response task belongs to the recipient"}:n===Kr?{de:"die Pr\xFCfung des R\xFCcklaufs entsteht erst mit dem R\xFCcklauf der Familie",en:"the check of the returned copy only arises once the family returns it"}:n===ut?{de:"die Kl\xE4rung der elektronischen Unterschrift entsteht erst, wenn sie nicht zustande kommt",en:"resolving the electronic signature only arises when it does not come about"}:{de:"die \xDCberarbeitungs-Aufgabe entsteht nur durch eine Ablehnung",en:"the revision task only arises from a rejection"};return{de:`[governedDocument/blocksTarget] 'blocks' auf "${n}" (Knoten "${e.id}") ist verboten \u2014 ${t.de}; zul\xE4ssige intrinsische Ziele: ${To}${e.approval==="release"?`, ${qr}`:""}.`,en:`[governedDocument/blocksTarget] 'blocks' on "${n}" (node "${e.id}") is not allowed \u2014 ${t.en}; allowed intrinsic targets: ${To}${e.approval==="release"?`, ${qr}`:""}.`}}return n===qr&&e.approval==="none"?{de:`[governedDocument/blocksTarget] 'blocks' auf "${qr}" auf Knoten "${e.id}" \u2014 mit approval 'none' existiert dieses Template nicht; der Blocker w\xFCrde ein Phantom aufschieben.`,en:`[governedDocument/blocksTarget] 'blocks' on "${qr}" on node "${e.id}" \u2014 with approval 'none' this template does not exist; the blocker would postpone a phantom.`}:null},"refuseBlocksTarget"),userUploadGate:s(async(e,n)=>{if(GL(n.node))return!1;let t=await Nv(e,n),r=(t==="awaitingResponse"||t==="responseReturned")&&Bi(n.node).producesResponseArtifact;return n.actor==="recipient"?r:t==="producing"&&n.node.production==="upload"||r},"userUploadGate"),userUploadConfirmation:s(async(e,n)=>{let t=VL(n.node);if(t===null||GL(n.node))return null;let r=await Nv(e,n);return r==="awaitingResponse"||r==="responseReturned"?t:null},"userUploadConfirmation"),validate:s((e,n,t)=>{let r=[];if(!Em(e))return r.push(Re(e,"modes",{de:`[governedDocument/unknownMode] Knoten "${e.id}" deklariert keine g\xFCltige Betriebsart \u2014 erforderlich: production \u2208 {${up.join(", ")}} (ist: ${JSON.stringify(e.production)}), approval \u2208 {${Po.join(", ")}} (ist: ${JSON.stringify(e.approval)}), responseStrategy \u2208 {${pp.join(", ")}} (ist: ${JSON.stringify(e.responseStrategy)}). Eine Betriebsart ist eine erkl\xE4rte Entscheidung, nie aus der Verdrahtung abgeleitet.`,en:`[governedDocument/unknownMode] Node "${e.id}" declares no valid mode \u2014 required: production \u2208 {${up.join(", ")}} (is: ${JSON.stringify(e.production)}), approval \u2208 {${Po.join(", ")}} (is: ${JSON.stringify(e.approval)}), responseStrategy \u2208 {${pp.join(", ")}} (is: ${JSON.stringify(e.responseStrategy)}). A mode is a declared decision, never derived from the wiring.`})),r;let i=ci[e.responseStrategy];e.production==="none"&&(e.approval!=="none"||e.responseStrategy!=="confirm")&&r.push(Re(e,"production",{de:`[governedDocument/modeContract] Knoten "${e.id}" hat production 'none' \u2014 ohne Dokument gibt es nichts freizugeben und nichts zu unterschreiben: approval muss 'none' sein (ist: '${e.approval}') und responseStrategy 'confirm' (ist: '${e.responseStrategy}').`,en:`[governedDocument/modeContract] Node "${e.id}" has production 'none' \u2014 with no document there is nothing to release and nothing to sign: approval must be 'none' (is: '${e.approval}') and responseStrategy 'confirm' (is: '${e.responseStrategy}').`}));let o=e.artifacts??[];if(e.production==="none")o.length!==0&&r.push(Re(e,"artifacts",{de:`[governedDocument/slotContract] Knoten "${e.id}" hat production 'none', deklariert aber ${o.length} Artefakt-Slot(s) \u2014 ein dokumentloser Best\xE4tigungs-Knoten verwaltet keinen Slot.`,en:`[governedDocument/slotContract] Node "${e.id}" has production 'none' but declares ${o.length} artifact slot(s) \u2014 a confirmation node without a document manages no slot.`}));else{o.length!==1&&r.push(Re(e,"artifacts",{de:`[governedDocument/slotContract] Knoten "${e.id}" deklariert ${o.length} Artefakt-Slots \u2014 genau EINER (das verwaltete Dokument) ist erforderlich.`,en:`[governedDocument/slotContract] Node "${e.id}" declares ${o.length} artifact slots \u2014 exactly ONE (the managed document) is required.`}));for(let v of o)v.visibility!=="external"&&r.push(Re(e,"artifacts",{de:`[governedDocument/slotContract] Slot "${v.key}" auf Knoten "${e.id}" hat visibility "${v.visibility}" \u2014 das verwaltete Dokument MUSS 'external' sein, sonst kann die bewerbende Person es auf /e nie sehen.`,en:`[governedDocument/slotContract] Slot "${v.key}" on node "${e.id}" has visibility "${v.visibility}" \u2014 the managed document MUST be 'external', otherwise the applicant can never see it on /e.`}))}let a=e.outcomes??[],l=a.map(v=>v.id),d=[i.acceptOutcomeId,i.declineOutcomeId];(a.length!==2||!d.every(v=>l.includes(v)))&&r.push(Re(e,"outcomes",{de:`[governedDocument/outcomeContract] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') muss genau ZWEI Outcomes deklarieren \u2014 das Accept-Terminal "${i.acceptOutcomeId}" und das Decline-Terminal "${i.declineOutcomeId}" (deklariert: ${l.length>0?l.map(v=>`"${v}"`).join(", "):"keine"}). Beide sind Pflicht: der Knoten besitzt die Antwort, nicht nur die Freigabe.`,en:`[governedDocument/outcomeContract] Node "${e.id}" (responseStrategy '${e.responseStrategy}') must declare exactly TWO outcomes \u2014 the accept terminal "${i.acceptOutcomeId}" and the decline terminal "${i.declineOutcomeId}" (declared: ${l.length>0?l.map(v=>`"${v}"`).join(", "):"none"}). Both are required: the node owns the answer, not only the release.`}));let c=e.titles,u=s(v=>{let E=c?.[v];return E===null||typeof E!="object"||!Object.values(E??{}).some(A=>typeof A=="string"&&A.length>0)},"missingTitle"),p=[];e.production!=="none"&&p.push("prepare","revise"),e.approval==="release"&&p.push("approve"),i.checksReturn&&p.push("check");let m=p.filter(u);m.length>0&&r.push(Re(e,"titles",{de:`[governedDocument/missingTitles] Knoten "${e.id}" fehlen die Aufgaben-Titel ${m.join(", ")} \u2014 der Knotentyp ist dokument-agnostisch, die Betitelung ist Pflicht-Konfiguration seiner Betriebsart.`,en:`[governedDocument/missingTitles] Node "${e.id}" is missing the task titles ${m.join(", ")} \u2014 the node type is document-agnostic, titling is required configuration of its mode.`}));let y=e.assign??{};if(e.production!=="none"){let v=y.prepareDocument;(typeof v!="string"||v.length===0)&&r.push(Re(e,"assign.prepareDocument",{de:`[governedDocument/productionAssign] Knoten "${e.id}" (production '${e.production}') verdrahtet kein Produzenten-Team (assign.prepareDocument) \u2014 ohne Producer-Aufgabe g\xE4be es die Submit-Aktion ohne freischaltendes Work-Item.`,en:`[governedDocument/productionAssign] Node "${e.id}" (production '${e.production}') wires no producer team (assign.prepareDocument) \u2014 without a producer task there would be the submit action without an enabling work item.`}))}if(e.approval==="none"&&(y.releaseApproval!==void 0&&r.push(Re(e,"assign.releaseApproval",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat approval 'none', verdrahtet aber assign.releaseApproval \u2014 tote Verdrahtung darf nicht als konfiguriert durchgehen (Betriebsart explizit \xE4ndern statt Gruppen zuweisen).`,en:`[governedDocument/deadWiring] Node "${e.id}" has approval 'none' but wires assign.releaseApproval \u2014 dead wiring must not pass as configured (change the mode explicitly instead of assigning groups).`})),c?.approve!==void 0&&r.push(Re(e,"titles.approve",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat approval 'none', deklariert aber titles.approve \u2014 es gibt keine Freigabe-Aufgabe, die diesen Titel tr\xFCge.`,en:`[governedDocument/deadWiring] Node "${e.id}" has approval 'none' but declares titles.approve \u2014 there is no release task that would carry this title.`}))),i.checksReturn){let v=y.responseCheck;(typeof v!="string"||v.length===0)&&r.push(Re(e,"assign.responseCheck",{de:`[governedDocument/checkAssign] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') verdrahtet kein Team f\xFCr die Pr\xFCfung des R\xFCcklaufs (assign.responseCheck) \u2014 ohne Team l\xE4ge jeder R\xFCcklauf bei niemandem.`,en:`[governedDocument/checkAssign] Node "${e.id}" (responseStrategy '${e.responseStrategy}') wires no team for checking the returned copy (assign.responseCheck) \u2014 without a team every returned copy would lie with nobody.`})),e.production!=="resolver"&&i.issuesBy==="provider"?r.push(Re(e,"responseStrategy",{de:`[governedDocument/eSignatureNeedsResolver] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben (eSignature), erzeugt das Dokument aber mit production '${e.production}' \u2014 der Anbieter bekommt eine eingefrorene Vertragsrevision mit Unterschriftsankern und deklarierten Unterzeichnern, und die entsteht nur mit production 'resolver'.`,en:`[governedDocument/eSignatureNeedsResolver] Node "${e.id}" is signed electronically (eSignature) but produces the document with production '${e.production}' \u2014 the provider gets a frozen contract revision with signature anchors and declared signatories, and that only exists with production 'resolver'.`})):e.production!=="resolver"&&r.push(Re(e,"responseStrategy",{de:`[governedDocument/checkNeedsContract] Knoten "${e.id}" pr\xFCft den R\xFCcklauf (signedUploadChecked), erzeugt das Dokument aber mit production '${e.production}' \u2014 die Pr\xFCfung hakt die unterzeichnenden Personen einer eingefrorenen Vertragsrevision ab, und die entsteht nur mit production 'resolver'.`,en:`[governedDocument/checkNeedsContract] Node "${e.id}" checks the returned copy (signedUploadChecked) but produces the document with production '${e.production}' \u2014 the check ticks off the signatories of a frozen contract revision, and that only exists with production 'resolver'.`}))}else{e.production==="resolver"&&r.push(Re(e,"responseStrategy",{de:`[governedDocument/contractNeedsCheckedReturn] Knoten "${e.id}" erzeugt einen Vertrag (production 'resolver'), beantwortet ihn aber mit '${e.responseStrategy}' \u2014 ein Vertrag gilt erst als unterschrieben, wenn die Schule den R\xFCcklauf gepr\xFCft hat oder ein Anbieter die Unterschrift belegt: responseStrategy muss 'signedUploadChecked' oder 'eSignature' sein (mit assign.responseCheck und titles.check).`,en:`[governedDocument/contractNeedsCheckedReturn] Node "${e.id}" produces a contract (production 'resolver') but answers it with '${e.responseStrategy}' \u2014 a contract only counts as signed once the school has checked the returned copy or a provider proves the signature: responseStrategy must be 'signedUploadChecked' or 'eSignature' (with assign.responseCheck and titles.check).`}));for(let[v,E]of[["assign.responseCheck",y.responseCheck!==void 0],["titles.check",c?.check!==void 0]])E&&r.push(Re(e,v,{de:`[governedDocument/deadWiring] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') deklariert ${v} \u2014 eine Pr\xFCfung des R\xFCcklaufs gibt es nur mit responseStrategy 'signedUploadChecked' oder 'eSignature'.`,en:`[governedDocument/deadWiring] Node "${e.id}" (responseStrategy '${e.responseStrategy}') declares ${v} \u2014 a check of the returned copy only exists with responseStrategy 'signedUploadChecked' or 'eSignature'.`}))}if(i.issuesBy==="provider"){let v=y.signingRecovery;(typeof v!="string"||v.length===0)&&r.push(Re(e,"assign.signingRecovery",{de:`[governedDocument/recoveryAssign] Knoten "${e.id}" l\xE4sst elektronisch unterschreiben, verdrahtet aber kein Team f\xFCr die Kl\xE4rung einer Unterschrift, die nicht zustande kommt (assign.signingRecovery) \u2014 \u201EErneut senden" und \u201EAuf Papier umstellen" l\xE4gen bei niemandem.`,en:`[governedDocument/recoveryAssign] Node "${e.id}" is signed electronically but wires no team for resolving a signature that does not come about (assign.signingRecovery) \u2014 "Send again" and "Switch to paper" would lie with nobody.`}))}else y.signingRecovery!==void 0&&r.push(Re(e,"assign.signingRecovery",{de:`[governedDocument/deadWiring] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') deklariert assign.signingRecovery \u2014 eine Kl\xE4rung der elektronischen Unterschrift gibt es nur mit responseStrategy 'eSignature'.`,en:`[governedDocument/deadWiring] Node "${e.id}" (responseStrategy '${e.responseStrategy}') declares assign.signingRecovery \u2014 resolving an electronic signature only exists with responseStrategy 'eSignature'.`}));if(i.issuesBy==="provider"&&r.push(...H3(e,t),...J3(e,t?.signingProvider)),e.confirmBeforeIssue!==void 0&&typeof e.confirmBeforeIssue!="boolean"?r.push(Re(e,"confirmBeforeIssue",{de:`[governedDocument/confirmBeforeIssue] Knoten "${e.id}" setzt confirmBeforeIssue auf ${JSON.stringify(e.confirmBeforeIssue)} \u2014 erlaubt ist nur true oder false.`,en:`[governedDocument/confirmBeforeIssue] Node "${e.id}" sets confirmBeforeIssue to ${JSON.stringify(e.confirmBeforeIssue)} \u2014 only true or false is allowed.`})):e.confirmBeforeIssue===!0&&e.approval==="release"&&r.push(Re(e,"confirmBeforeIssue",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat approval 'release', deklariert aber confirmBeforeIssue \u2014 \u201EFreigabe anfordern" schickt noch nichts an die Familie, und die Freigabe selbst ist die bewusste Pr\xFCfung vor dem Versand. Die R\xFCckfrage gibt es nur mit approval 'none'.`,en:`[governedDocument/deadWiring] Node "${e.id}" has approval 'release' but declares confirmBeforeIssue \u2014 "Request release" sends nothing to the family yet, and the release itself is the deliberate check before sending. The confirmation prompt only exists with approval 'none'.`})),e.confirmContractTerms!==void 0&&typeof e.confirmContractTerms!="boolean"&&r.push(Re(e,"confirmContractTerms",{de:`[governedDocument/confirmContractTerms] Knoten "${e.id}" setzt confirmContractTerms auf ${JSON.stringify(e.confirmContractTerms)} \u2014 erlaubt ist nur true oder false.`,en:`[governedDocument/confirmContractTerms] Node "${e.id}" sets confirmContractTerms to ${JSON.stringify(e.confirmContractTerms)} \u2014 only true or false is allowed.`})),Pd(e))e.confirmContractTerms===!1&&e.contractTermsQuestionText!==void 0&&r.push(Re(e,"contractTermsQuestionText",{de:`[governedDocument/deadWiring] Knoten "${e.id}" schaltet die Best\xE4tigung der Vertragsbedingungen ab (confirmContractTerms: false), formuliert aber die Frage um \u2014 ohne Best\xE4tigung wird sie nie gestellt.`,en:`[governedDocument/deadWiring] Node "${e.id}" switches off the confirmation of the contract terms (confirmContractTerms: false) but rewords the question \u2014 without the confirmation it is never asked.`}));else for(let[v,E]of[["confirmContractTerms",e.confirmContractTerms!==void 0],["contractTermsQuestionText",e.contractTermsQuestionText!==void 0]])E&&r.push(Re(e,v,{de:`[governedDocument/deadWiring] Knoten "${e.id}" (responseStrategy '${e.responseStrategy}') deklariert ${v} \u2014 die Best\xE4tigung der Vertragsbedingungen geh\xF6rt zum Hochladen der unterschriebenen Fassung, das es nur mit responseStrategy 'signedUpload' oder 'signedUploadChecked' gibt.`,en:`[governedDocument/deadWiring] Node "${e.id}" (responseStrategy '${e.responseStrategy}') declares ${v} \u2014 the confirmation of the contract terms belongs to uploading the signed copy, which only exists with responseStrategy 'signedUpload' or 'signedUploadChecked'.`}));if(e.production==="none")for(let[v,E]of[["confirmBeforeIssue",e.confirmBeforeIssue===!0],["assign.prepareDocument",y.prepareDocument!==void 0],["titles.prepare",c?.prepare!==void 0],["titles.revise",c?.revise!==void 0]])E&&r.push(Re(e,v,{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production 'none', deklariert aber ${v} \u2014 ohne Produktionsphase gibt es keinen Tr\xE4ger daf\xFCr.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production 'none' but declares ${v} \u2014 without a production phase there is nothing to carry it.`}));for(let v of e.tasks??[])Pv.has(v.key)&&r.push(Re(e,`tasks.${v.key}`,{de:`[governedDocument/keyShadowsIntrinsic] Task-Key "${v.key}" auf Knoten "${e.id}" kollidiert mit einem intrinsischen Template (${[...Pv].join(", ")}) \u2014 anderen Key w\xE4hlen.`,en:`[governedDocument/keyShadowsIntrinsic] Task key "${v.key}" on node "${e.id}" collides with an intrinsic template (${[...Pv].join(", ")}) \u2014 choose another key.`}));if(e.production==="resolver"?r.push(...V3(e,t)):e.inputs?.[_t]!==void 0&&r.push(Re(e,`inputs.${_t}`,{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production '${e.production}', nennt aber einen Tr\xE4ger \u2014 nur ein erzeugter Vertrag hat eine Vertragspartei der Schule.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production '${e.production}' but names a legal entity \u2014 only a generated contract has a contracting party on the school's side.`})),r.push(...K3(e)),e.production==="resolver"){let v=ni(e);if(v!==null){let E=lI(v);for(let A of Tm(e)){if(!_i(A.type)){r.push(Re(e,`generatorStamp.inputSchema.${A.key}`,{de:`[governedDocument/unknownFieldType] Generator "${E}" typisiert das Feld "${A.key}" als "${String(A.type)}" \u2014 das geh\xF6rt nicht zum Wert-Vokabular der Plattform (${Os.join(", ")}). Die gepinnte Revision stammt aus einer \xE4lteren Fassung und muss neu versiegelt werden.`,en:`[governedDocument/unknownFieldType] Generator "${E}" types the field "${A.key}" as "${String(A.type)}" \u2014 that is not part of the platform's value vocabulary (${Os.join(", ")}). The pinned revision comes from an older version and must be sealed again.`}));continue}if(A.type==="personList"){r.push(Re(e,`generatorStamp.inputSchema.${A.key}`,{de:`[governedDocument/partyListUnsupported] Generator "${E}" deklariert das Feld "${A.key}" als personList \u2014 daf\xFCr gibt es keine Platzhalter-Heimat im Dokument und keine Eingabe. Eine Liste von Personen geh\xF6rt als Rolle mit Kapazit\xE4t deklariert oder als berechneter Textwert.`,en:`[governedDocument/partyListUnsupported] Generator "${E}" declares the field "${A.key}" as personList \u2014 there is no placeholder home for it in the document and no input. A list of people belongs declared as a role with capacity or as a computed text value.`}));continue}A.type==="party"&&(A.key.endsWith("PartyId")||r.push(Re(e,`generatorStamp.inputSchema.${A.key}`,{de:`[governedDocument/partyFieldKey] Party-Feld "${A.key}" endet nicht auf "PartyId" \u2014 aus diesem Suffix wird der Platzhalter-Pr\xE4fix im Dokument abgeleitet (emergencyContactPartyId \u2192 emergency_contact).`,en:`[governedDocument/partyFieldKey] Party field "${A.key}" does not end in "PartyId" \u2014 the placeholder prefix in the document is derived from this suffix (emergencyContactPartyId \u2192 emergency_contact).`})))}r.push(...JL(e,{de:`"${E}"`,en:`"${E}"`}))}}else e.generatorStamp!==void 0&&r.push(Re(e,"generatorStamp",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production '${e.production}', tr\xE4gt aber den Stempel eines Generators \u2014 ohne maschinelle Produktion l\xE4uft keiner.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production '${e.production}' but carries a generator stamp \u2014 without machine production none runs.`}));e.production==="template"?r.push(...Y3(e)):e.templateStamp!==void 0&&r.push(Re(e,"templateStamp",{de:`[governedDocument/deadWiring] Knoten "${e.id}" hat production '${e.production}', tr\xE4gt aber die Parameter einer Vorlage \u2014 ohne Vorlagen-Produktion wird sie nie gef\xFCllt.`,en:`[governedDocument/deadWiring] Node "${e.id}" has production '${e.production}' but carries a template's parameters \u2014 without template production it is never filled.`}));let k=e.inputs?.[di],g=k===void 0||k.kind==="unset"?void 0:k.kind==="literal"?k.value:k;return g!==void 0&&!ql(g)&&r.push(Re(e,`inputs.${di}`,{de:`[governedDocument/dueInDays] Knoten "${e.id}" setzt responseDueInDays auf ${JSON.stringify(g)} \u2014 erlaubt ist eine ganze Zahl von ${Io} bis ${Oo} Tagen.`,en:`[governedDocument/dueInDays] Node "${e.id}" sets responseDueInDays to ${JSON.stringify(g)} \u2014 a whole number from ${Io} to ${Oo} days is allowed.`})),g===void 0&&Tm(e).some(v=>v.processSource==="responseDueInDays")&&r.push(Re(e,`inputs.${di}`,{de:`[governedDocument/dueInDays] Knoten "${e.id}" druckt die Antwortfrist (processSource 'responseDueInDays'), setzt aber kein responseDueInDays \u2014 das Dokument nennte eine Frist, die es nicht gibt.`,en:`[governedDocument/dueInDays] Node "${e.id}" prints the response deadline (processSource 'responseDueInDays') but sets no responseDueInDays \u2014 the document would name a deadline that does not exist.`})),r},"validate")};var ZL={addPupil:{method:"POST",path:"/api/v1/admissions/AddPrPupilBasic/{schoolid}",kind:"create",body:"PrPupilBasicCreate",required:["forename","surname","genderId"],maxLength:{titleId:4,forename:50,surname:50,middleName:50,preferredForename:50,preferredSurname:50,genderId:4,firstLanguage:4}},addAdmissionDetails:{method:"POST",path:"/api/v1/admissions/AddAdmissionDetails/{schoolid}/{pupilid}",kind:"create",body:"AddPrPupilAdmissionDetails",required:[],maxLength:{boarderStatusId:4,ageAdjust:4,entryYear:4,entryTerm:4,entryYearGroup:4,currentSchoolId:20,enquirySource:4,currentAdmissionStageId:25}},addNationality:{method:"POST",path:"/api/v1/admissions/AddNationlityInfo/{schoolid}/{pupilid}",kind:"create",body:"NationalityInfoCreate",required:["nationalityId"],maxLength:{nationalityId:4,countryOfBirth:4}},addVisa:{method:"POST",path:"/api/v1/admissions/AddVisaInfo/{schoolid}/{pupilid}",kind:"create",body:"CreateVisaInfo",required:[],maxLength:{placeOfBirth:50,passportCountry:4,passportNumber:50,residenceVisaNumber:50,healthCardNumber:50}},addMedical:{method:"POST",path:"/api/v1/admissions/AddMedicalInfo/{schoolid}/{pupilid}",kind:"create",body:"MedicalInfoCreate",required:[],maxLength:{}},addContact:{method:"POST",path:"/api/v1/admissions/AddContactBasicInfo/{schoolid}/{pupilid}",kind:"create",body:"AddContactBasicInfo",required:["titleId","firstName","lastName","genderId"],maxLength:{relationshipId:4,titleId:4,firstName:50,middleName:50,lastName:50,contactName:200,greeting:200,languageId:4,secondLanguageId:4,genderId:4,professionId:4,companyName:50,jobTitle:50}},linkExistingContact:{method:"POST",path:"/api/v1/admissions/LinkExistingContact/{schoolid}/{pupilid}/{contactid}",kind:"create",body:"LinkContact",required:["relationshipId"],maxLength:{relationshipId:4}},addContactAddress:{method:"POST",path:"/api/v1/admissions/AddContactAddressNew/{schoolid}/{contactid}/{addressformatid}",kind:"create",body:"AddAddressVM",required:["countryId"],maxLength:{addressTypeId:4,countryId:4,addressLine1:100,addressLine2:100,addressLine3:100,addressLine4:100,addressLine5:100,addressLine6:100,lookup1:4,lookup2:4,lookup3:4,lookup4:4,lookup5:4}},addContactEmail:{method:"POST",path:"/api/v1/admissions/AddContactEmail/{schoolid}/{contactid}",kind:"create",body:"AddEmailAddress",required:["emailTypeId","email"],maxLength:{emailTypeId:4,email:254}},addContactTelephone:{method:"POST",path:"/api/v1/admissions/AddContactTelephone/{schoolid}/{contactid}",kind:"create",body:"AddTelephoneNumber",required:["typeId","number"],maxLength:{typeId:4}},linkAddressToPupil:{method:"PUT",path:"/api/v1/admissions/LinkAddressToPupil/{schoolId}/{pupilId}/{addressId}",kind:"update",required:[],maxLength:{}},updatePupilAif:{method:"POST",path:"/api/v1/additionalinformation/UpdatePupilAIF/{schoolid}/{pupilid}",kind:"update",body:"AifFieldValueVM",required:[],maxLength:{}},updateContactAif:{method:"POST",path:"/api/v1/additionalinformation/UpdateContactAIF/{schoolid}/{contactid}",kind:"update",body:"AifFieldValueVM",required:[],maxLength:{}},listPupils:{method:"GET",path:"/api/v1/admissions/GetPrPupilBasicInfo/{schoolid}",kind:"read",required:[],maxLength:{}},getPupil:{method:"GET",path:"/api/v1/admissions/GetPrPupilBasicInfoById/{schoolid}/{pupilid}",kind:"read",required:[],maxLength:{}},listContactsOfPupil:{method:"GET",path:"/api/v1/admissions/GetContactBasicInfoByPupilId/{schoolid}/{pupilid}",kind:"read",required:[],maxLength:{}},getContact:{method:"GET",path:"/api/v1/admissions/GetContactByContactId/{schoolid}/{contactid}",kind:"read",required:[],maxLength:{}}};function qt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(qt,"isRecord");var _v=["field","join","literal","address","payment","contract"],Q3=new Set(["text","date","datetime","bool","aifBool","money","moneyText"]),Z3=new Set(["street","streetAndNumber","hausnr","plz","ort","land","full"]);function tr(e){return typeof e=="string"&&e.trim().length>0}s(tr,"nonEmptyString");function $m(e,n,t,r,i="value"){if(!qt(e)||!qt(e.from)){r.push({path:n,code:"mappingShape",message:{de:`${n}: eine Zuordnung braucht \`from\`.`,en:`${n}: a mapping needs \`from\`.`}});return}let o=e.from,a=_v.filter(c=>c in o);if(a.length!==1){r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from\` nennt genau eine Quelle (${_v.join(" | ")}).`,en:`${n}: \`from\` names exactly one source (${_v.join(" | ")}).`}});return}let[l]=a;l==="field"&&!tr(o.field)&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.field\` ist leer.`,en:`${n}: \`from.field\` is empty.`}}),l==="join"&&!(Array.isArray(o.join)&&o.join.length>=2&&o.join.every(tr))&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.join\` nennt mindestens zwei Formularfelder.`,en:`${n}: \`from.join\` names at least two form fields.`}}),e.whenEmpty!==void 0&&(i==="condition"?r.push({path:n,code:"mappingShape",message:{de:`${n}: \`whenEmpty\` gilt nicht f\xFCr eine Bedingung (\`unless\`, \`linkAddressToPupilIf\`).`,en:`${n}: \`whenEmpty\` does not apply to a condition (\`unless\`, \`linkAddressToPupilIf\`).`}}):l!=="field"&&l!=="join"?r.push({path:n,code:"mappingShape",message:{de:`${n}: \`whenEmpty\` gilt nur f\xFCr eine Formularantwort (\`field\`, \`join\`).`,en:`${n}: \`whenEmpty\` applies only to a form answer (\`field\`, \`join\`).`}}):typeof e.whenEmpty=="boolean"||Number.isFinite(e.whenEmpty)||tr(e.whenEmpty)||r.push({path:n,code:"mappingShape",message:{de:`${n}: \`whenEmpty\` ist ein Engage-Wert (Text, Zahl oder ja/nein).`,en:`${n}: \`whenEmpty\` is an Engage value (text, number or yes/no).`}})),l==="address"&&!(we(o.address)&&o.address.scope==="env"&&Wt(o.address.key))&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.address\` ist eine Umgebungsvariable (\`{ scope: 'env', key: 'stage.key' }\`).`,en:`${n}: \`from.address\` is an environment value (\`{ scope: 'env', key: 'stage.key' }\`).`}}),l==="payment"&&o.payment!=="amount"&&o.payment!=="settledAt"&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.payment\` ist amount oder settledAt.`,en:`${n}: \`from.payment\` is amount or settledAt.`}}),l==="contract"&&!["startDate","signedAt","createdAt"].includes(String(o.contract))&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.contract\` ist startDate, signedAt oder createdAt.`,en:`${n}: \`from.contract\` is startDate, signedAt or createdAt.`}}),l==="literal"&&!["string","number","boolean"].includes(typeof o.literal)&&r.push({path:n,code:"mappingShape",message:{de:`${n}: \`from.literal\` ist Text, Zahl oder ja/nein.`,en:`${n}: \`from.literal\` is text, a number or yes/no.`}}),e.format!==void 0&&!Q3.has(String(e.format))&&r.push({path:n,code:"mappingShape",message:{de:`${n}: unbekanntes Format \u201E${String(e.format)}".`,en:`${n}: unknown format "${String(e.format)}".`}}),e.lookup!==void 0&&!(tr(e.lookup)&&qt(t[e.lookup]))&&r.push({path:n,code:"unknownLookup",message:{de:`${n}: die Lookup-Tabelle \u201E${String(e.lookup)}" fehlt in \`lookups\`.`,en:`${n}: the lookup table "${String(e.lookup)}" is missing from \`lookups\`.`}});let d=e.pick;d!==void 0&&(d==="firstWord"||d==="restWords"||d==="year"||qt(d)&&Number.isInteger(d.index)&&Number(d.index)>=0||qt(d)&&Z3.has(String(d.address))||r.push({path:n,code:"mappingShape",message:{de:`${n}: unbekannte Auswahl \`pick\`.`,en:`${n}: unknown selection \`pick\`.`}}))}s($m,"checkMapping");function Gi(e,n,t,r,i){if(!qt(e)){i.push({path:n,code:"bodyShape",message:{de:`${n}: erwartet ein Objekt Feld \u2192 Zuordnung.`,en:`${n}: expects an object field \u2192 mapping.`}});return}let o=ZL[t];for(let a of o.required)a in e||i.push({path:`${n}.${a}`,code:"missingRequired",message:{de:`${n}: Engage verlangt \u201E${a}" (${o.body}) \u2014 es fehlt eine Zuordnung.`,en:`${n}: Engage requires "${a}" (${o.body}) \u2014 a mapping is missing.`}});for(let[a,l]of Object.entries(e))$m(l,`${n}.${a}`,r,i)}s(Gi,"checkBody");function XL(e,n,t,r){if(e===void 0)return;if(!Array.isArray(e)){r.push({path:n,code:"bodyShape",message:{de:`${n}: erwartet eine Liste.`,en:`${n}: expects a list.`}});return}let i=new Set;e.forEach((o,a)=>{let l=`${n}[${a}]`;if(!qt(o)||!tr(o.fieldId)){r.push({path:l,code:"aifShape",message:{de:`${l}: \`fieldId\` fehlt.`,en:`${l}: \`fieldId\` is missing.`}});return}i.has(o.fieldId)&&r.push({path:l,code:"aifDuplicate",message:{de:`${l}: \u201E${o.fieldId}" doppelt.`,en:`${l}: "${o.fieldId}" appears twice.`}}),i.add(o.fieldId),$m(o.value,`${l}.value`,t,r),o.unless!==void 0&&$m(o.unless,`${l}.unless`,t,r,"condition")})}s(XL,"checkAif");function Cv(e){let n=[];if(!qt(e))return[{path:"engage",code:"missing",message:{de:"Die Engage-Zuordnung `engage` fehlt.",en:"The Engage mapping `engage` is missing."}}];let t=qt(e.lookups)?e.lookups:{};qt(e.lookups)||n.push({path:"engage.lookups",code:"bodyShape",message:{de:"`engage.lookups` fehlt (Tabellen Name \u2192 Plexus-Wert \u2192 Engage-Id).",en:"`engage.lookups` is missing (tables name \u2192 Plexus value \u2192 Engage id)."}});for(let[r,i]of Object.entries(t))(!qt(i)||!Object.values(i).every(tr))&&n.push({path:`engage.lookups.${r}`,code:"lookupShape",message:{de:`Lookup \u201E${r}": jede Engage-Id ist ein nicht leerer Text.`,en:`Lookup "${r}": every Engage id is a non-empty text.`}});if(tr(e.addressFormatId)||n.push({path:"engage.addressFormatId",code:"missing",message:{de:"`engage.addressFormatId` fehlt (GetAddressMappingInfo).",en:"`engage.addressFormatId` is missing (GetAddressMappingInfo)."}}),Gi(e.pupil,"engage.pupil","addPupil",t,n),Gi(e.admission,"engage.admission","addAdmissionDetails",t,n),e.nationality!==void 0&&Gi(e.nationality,"engage.nationality","addNationality",t,n),e.visa!==void 0&&Gi(e.visa,"engage.visa","addVisa",t,n),e.medical!==void 0&&Gi(e.medical,"engage.medical","addMedical",t,n),XL(e.pupilAif,"engage.pupilAif",t,n),!Array.isArray(e.contacts))n.push({path:"engage.contacts",code:"bodyShape",message:{de:"`engage.contacts` fehlt (Liste der Kontakte).",en:"`engage.contacts` is missing (list of contacts)."}});else{let r=new Set;e.contacts.forEach((i,o)=>{let a=`engage.contacts[${o}]`;if(!qt(i)||!tr(i.key)||!tr(i.presentIf)){n.push({path:a,code:"contactShape",message:{de:`${a}: \`key\` und \`presentIf\` fehlen.`,en:`${a}: \`key\` and \`presentIf\` are missing.`}});return}r.has(i.key)&&n.push({path:a,code:"contactDuplicate",message:{de:`${a}: Kontakt \u201E${i.key}" doppelt.`,en:`${a}: contact "${i.key}" appears twice.`}}),r.add(i.key),Gi(i.basic,`${a}.basic`,"addContact",t,n),i.address!==void 0&&Gi(i.address,`${a}.address`,"addContactAddress",t,n);for(let[l,d]of[["emails","addContactEmail"],["telephones","addContactTelephone"]]){let c=i[l];if(c!==void 0){if(!Array.isArray(c)){n.push({path:`${a}.${l}`,code:"bodyShape",message:{de:`${a}.${l}: erwartet eine Liste.`,en:`${a}.${l}: expects a list.`}});continue}c.forEach((u,p)=>Gi(u,`${a}.${l}[${p}]`,d,t,n))}}XL(i.aif,`${a}.aif`,t,n),i.linkAddressToPupilIf!==void 0&&$m(i.linkAddressToPupilIf,`${a}.linkAddressToPupilIf`,t,n,"condition")})}if(e.siblingsAttending!==void 0){let r=e.siblingsAttending;(!qt(r)||!tr(r.repeated)||!tr(r.field)||!tr(r.equals))&&n.push({path:"engage.siblingsAttending",code:"bodyShape",message:{de:"`engage.siblingsAttending` braucht repeated, field und equals.",en:"`engage.siblingsAttending` needs repeated, field and equals."}})}return n}s(Cv,"engagePushConfigIssues");function*Dv(e){let n=[e.pupil,e.admission,e.nationality,e.visa,e.medical];for(let t of n)for(let r of Object.values(t??{}))yield{mapping:r};for(let t of e.pupilAif??[])yield{mapping:t.value},t.unless!==void 0&&(yield{mapping:t.unless});for(let t of e.contacts){let r=[t.basic,t.address,...t.emails??[],...t.telephones??[]];for(let i of r)for(let o of Object.values(i??{}))yield{mapping:o,contactKey:t.key};for(let i of t.aif??[])yield{mapping:i.value,contactKey:t.key},i.unless!==void 0&&(yield{mapping:i.unless,contactKey:t.key});t.linkAddressToPupilIf!==void 0&&(yield{mapping:t.linkAddressToPupilIf,contactKey:t.key})}}s(Dv,"mappingsOf");function e0(e){let n=new Set(e.contacts.map(t=>t.presentIf));for(let{mapping:t,contactKey:r}of Dv(e))for(let i of X3(t.from))n.add(e5(i,r));return[...n]}s(e0,"configFieldKeys");function X3(e){return"field"in e?[e.field]:"join"in e?e.join:[]}s(X3,"formFieldsOf");function e5(e,n){return e.startsWith(".")?(n===void 0&&F(`[engagePush] relative field "${e}" outside a contact`),`${n}${e}`):e}s(e5,"resolveFieldKey");function n0(e,n){for(let{mapping:t}of Dv(e))if(n in t.from)return!0;return!1}s(n0,"configReadsSource");function t0(e){let n=new Set;for(let{mapping:t}of Dv(e))"address"in t.from&&n.add(t.from.address.key);return[...n]}s(t0,"configEnvLeaves");var r0="done",i0=["sandbox","production"];var Rm="engagePush",UNe=660*1e3;function zi(e,n,t,r="error"){return{layer:"GRAPH",kind:"nodeRule",path:`nodes.${e.id}.${n}`,reason:t,severity:r}}s(zi,"issue");function Fv(e,n){let t=e.inputs?.[n];return t?.kind==="literal"?t.value:void 0}s(Fv,"literal");function o0(e){return Cv(e.engage).length===0?e.engage:null}s(o0,"validConfig");function n5(e,n){let t=new Map(e.nodes.map(a=>[a.id,a])),r=e.nodes.filter(a=>a.type==="eventTrigger"),i=new Set,o=r.map(a=>a.id);for(;o.length>0;){let a=o.pop();if(a===n||i.has(a))continue;i.add(a);let l=t.get(a);if(l!==void 0){if(l.type==="end"){let d=l.inputs?.applicationOutcome;if(d?.kind==="literal"&&d.value==="approved")return!0;continue}for(let d of Object.values(l.next??{})){let c=d?.to;typeof c=="string"&&o.push(c)}}}return!1}s(n5,"bypassingPath");var s0={role:"system-action",effect:"side-effect",outcomes:[{id:r0,label:{de:"Angesto\xDFen",en:"Started"}}],envReads:s(e=>{let n=o0(e);return n===null?[]:t0(n)},"envReads"),inputs:s(()=>[{id:"target",label:{de:"Ziel-Engage",en:"Target Engage"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:[{value:"sandbox",label:{de:"Sandbox",en:"Sandbox"}},{value:"production",label:{de:"Produktion",en:"Production"}}]},{id:"contractFields",label:{de:"Vertragsfelder F01\u2013F25",en:"Contract fields F01\u2013F25"},type:"enum",required:!1,inspector:"literal-only",optionSource:"declared",enumOptions:[{value:"off",label:{de:"Nicht \xFCbertragen (Bedeutung offen)",en:"Do not transfer (meaning open)"}},{value:"on",label:{de:"\xDCbertragen",en:"Transfer"}}]}],"inputs"),validate:s((e,n,t)=>{let r=e.label?.de??e.id,i=e.label?.en||e.id,o=[],a=Fv(e,"target");i0.includes(a)||o.push(zi(e,"inputs.target",{de:`[engagePush/invalidTarget] \u201E${r}": das Ziel ist sandbox oder production.`,en:`[engagePush/invalidTarget] "${i}": the target is sandbox or production.`}));let l=Fv(e,"contractFields");l!==void 0&&l!=="off"&&l!=="on"&&o.push(zi(e,"inputs.contractFields",{de:`[engagePush/contractFields] \u201E${r}": Vertragsfelder sind off oder on.`,en:`[engagePush/contractFields] "${i}": contract fields are off or on.`}));let d=e.assign?.[Rm];(typeof d!="string"||d.length===0)&&o.push(zi(e,"assign",{de:`[engagePush/assign] \u201E${r}": wer eine stehen gebliebene \xDCbertragung pr\xFCft, fehlt \u2014 \`assign.${Rm}\` nennt das Team.`,en:`[engagePush/assign] "${i}": nobody is set to check a stalled transfer \u2014 \`assign.${Rm}\` names the team.`}));for(let g of Cv(e.engage))o.push(zi(e,g.path,{de:`[engagePush/config] \u201E${r}": ${g.message.de}`,en:`[engagePush/config] "${i}": ${g.message.en}`}));let c=n.nodes.filter(g=>g.id!==e.id&&g.type==="engagePush"&&Fv(g,"target")===a);c.length>0&&o.push(zi(e,"inputs.target",{de:`[engagePush/twice] \u201E${r}": ${c.map(g=>`"${g.id}"`).join(", ")} \xFCbertr\xE4gt schon an dasselbe Ziel.`,en:`[engagePush/twice] "${i}": ${c.map(g=>`"${g.id}"`).join(", ")} already transfers to the same target.`})),n5(n,e.id)&&o.push(zi(e,"next",{de:`[engagePush/bypassed] \u201E${r}": ein Weg erreicht ein \u201Eangenommen"-Ende, ohne durch die Engage-\xDCbertragung zu laufen \u2014 was dort angenommen wird, k\xE4me nie in Engage an.`,en:`[engagePush/bypassed] "${i}": a path reaches an "accepted" end without passing through the Engage transfer \u2014 what is accepted there would never reach Engage.`}));let u=o0(e),p=e;for(let[g,v,E,A]of[["contract","contract","Vertrag","Contract"],["payment","payment","Zahlung","Payment"]])u===null||!n0(u,g)||p[v]!==void 0||o.push(zi(e,v,{de:Cs("address/missing",{where:`\u201E${r}\u201C \u203A ${E}`},"de"),en:Cs("address/missing",{where:`"${i}" \u203A ${A}`},"en")}));let m=p.form,y=we(m)&&m.scope==="node"?m.owner:void 0,k=y===void 0?void 0:t?.readinessFormFieldsByFormNode?.get(y);if(u!==null&&k!==void 0){let g=new Set(k.keys()),v=e0(u).filter(E=>!g.has(E)&&!/\[\d+\]\./.test(E));if(v.length>0){let E=n.nodes.find(A=>A.id===y);o.push(zi(e,"engage",{de:`[engagePush/unmappedField] \u201E${r}": diese Felder kennt das Formular \u201E${E?.label?.de??y}" nicht \u2014 sie werden nicht \xFCbertragen: ${v.join(", ")}.`,en:`[engagePush/unmappedField] "${i}": the form "${E?.label?.en||y}" does not know these fields \u2014 they are not transferred: ${v.join(", ")}.`},"warning"))}}return o},"validate")};var Vo={join:KF,end:JO,roleAssign:BF,eventTrigger:VF,waitlist:oL,completenessCheck:pL,form:JF,setFlag:QF,if:ZF,decision:Bo,review:hL,collectPayment:vL,governedDocument:QL,countersign:b_,engagePush:s0};HI(Vo);function a0(e,n){let t=e;if(t==null||!Array.isArray(t.nodes))throw new Error(`offer plan: the ${n} carries no workflow graph with nodes`);return e}s(a0,"graphOf");function l0(e){let n=new Map;for(let t of e.nodes)for(let r of Dr(e,t))n.set(se(r.address),r.nodeId);return n}s(l0,"producedOf");function d0(e){let n=new Map;for(let t of e.nodes)n.set(t.id,new Set(bo(e,t).map(r=>se(r.address))));return n}s(d0,"readsOf");function c0(e,n){let t=a0(e,"bundle"),r=a0(n.graph,"live head"),i=l0(t),o=l0(r),a={added:[],removed:[],moved:[]};for(let[u,p]of i){let m=o.get(u);m===void 0?a.added.push({address:u,nodeId:p}):m!==p&&a.moved.push({address:u,from:m,to:p})}for(let[u,p]of o)i.has(u)||a.removed.push({address:u,nodeId:p});let l=d0(t),d=d0(r),c=[];for(let u of new Set([...l.keys(),...d.keys()])){let p=l.get(u)??new Set,m=d.get(u)??new Set,y=[...p].filter(g=>!m.has(g)),k=[...m].filter(g=>!p.has(g));(y.length>0||k.length>0)&&c.push({nodeId:u,added:y,removed:k})}return{headRevision:n.revision,pinnedApplications:n.pinnedApplications,produced:a,reads:c}}s(c0,"planAddresses");function u0(e){let n=[...e.produced.moved.map(i=>({icon:"~",target:`address:${i.address}`,status:`Knoten ${i.from} \u2192 ${i.to}`})),...e.produced.added.map(i=>({icon:"+",target:`address:${i.address}`,status:`neu (${i.nodeId})`})),...e.produced.removed.map(i=>({icon:"-",target:`address:${i.address}`,status:`entfernt (${i.nodeId})`})),...e.reads.map(i=>({icon:"~",target:`reads:${i.nodeId}`,status:[i.added.length>0?`+${i.added.join(", ")}`:"",i.removed.length>0?`\u2212${i.removed.join(", ")}`:""].filter(Boolean).join(" ")}))];if(n.length===0)return[];let{real:t,test:r}=e.pinnedApplications;return n.push({icon:"!",target:"pinned",status:`${t+r} Anmeldungen (${t} echt, ${r} Test) auf Fassung ${e.headRevision} bleiben auf ihrer Version \u2014 Umpinnen nur per Migration mit Abbildung`}),n}s(u0,"addressPlanRows");function f0(e,n){return n==null?!0:Pe(e)!==Pe(n)}s(f0,"changed");async function p0(e,n,t){if(n.index.module!==ev.name)throw new Error(`offer: unknown module "${n.index.module}"`);return Z_(e,n,t,{afterManifestPublish:s(async()=>{if(n.index.links?.unitKey||n.index.program)return ev.scaffold(e,n.index.slugs.manifest,n.index,{dryRun:t.dryRun??!1})},"afterManifestPublish")})}s(p0,"applyOffer");async function m0(e,n,t,r="published"){let i=await e.query(x.setup.offerBundle.exportOfferBundle,{client:n,offerKey:t,generation:r});return{bundle:i.bundle,generation:i.generation,revision:i.revision}}s(m0,"exportOffer");async function Lv(e,n){let{index:t}=n,i=(await e.query(x.workflow.listManifests,{client:t.tenant})).find(y=>y.offerKey===t.slugs.manifest),o="create";i&&(o="same");let a={};for(let[y,k]of Object.entries(n.smartforms??{})){let g=i?await e.query(x.forms.getSmartFormBySlug,{client:t.tenant,offerVersionId:i.offerVersionId,slug:y}):null;a[y]=g?.def?f0(k,{label:g.def.label,...g.def.definition})?"change":"same":"create"}let l="absent",d=null;if(n.workflow!==void 0){if(l="create",i?.workflowDefinitionId){let y=await e.query(x.workflow.getWorkflowDef,{workflowDefinitionId:i.workflowDefinitionId}),k=y?.publishedVersion??y?.draftVersion;l=f0(k&&{graph:bs(n.workflow.graph),progressLayout:n.workflow.progressLayout??k.progressLayout,progressWiring:n.workflow.progressWiring??k.progressWiring},k&&{graph:bs(k.graph),progressLayout:k.progressLayout,progressWiring:k.progressWiring})?"change":"same"}if(i){let y=await e.query(x.workflow.getOfferHeadPins,{client:t.tenant,offerKey:t.slugs.manifest});y!==null&&(d=c0(n.workflow.graph,y))}}let c=t.program?.stages,u=c===void 0?[]:i?await Xb(e,t.tenant,t.slugs.manifest,c):cm(null,[],c),p=await hm(e,t.tenant,i?t.slugs.manifest:null,t),m=i?await e.query(x.workflow.getOfferPublishState,{client:t.tenant,offerKey:t.slugs.manifest}):null;return{manifest:o,smartforms:a,workflow:l,addresses:d,stages:u,capacities:p,publishPending:m?.draftDiffersFromExternal??null,draftRevision:m?.draftRevision??null,externalHeadRevision:m?.externalHeadRevision??null}}s(Lv,"diffOffer");function Im(e){if(e.type==="governedDocument"){let n=e.production;return n==="resolver"?"resolver":n==="template"?"template":n==="upload"||n==="none"?"manual":"unauthored"}return null}s(Im,"contractProductionModeOf");function h0(e){return Im(e)==="resolver"}s(h0,"isResolverCarrierNode");function Om(e){return(e.workflow?.graph?.nodes??[]).flatMap(t=>{let r=ni(t);return!h0(t)||r===null?[]:[{node:t,key:r.key,kind:r.kind,...r.revision===void 0?{}:{revision:r.revision}}]})}s(Om,"authoredPins");var g0={type:"address",dataType:"composite"};var y0={type:"boolean",dataType:"boolean"};var w0={type:"consent",dataType:"boolean"};var k0={type:"date",dataType:"date"};var b0={type:"docRef",dataType:"file"};var v0={type:"email",dataType:"text"};var x0={type:"enum",dataType:"option"};var S0={type:"string",dataType:"text"};var A0={type:"tel",dataType:"text"};var Pm={address:g0.dataType,boolean:y0.dataType,consent:w0.dataType,date:k0.dataType,docRef:b0.dataType,email:v0.dataType,enum:x0.dataType,string:S0.dataType,tel:A0.dataType};function Mv(e){return{type:e.type,multiple:e.multiple===!0,enumListKey:e.enumListKey,enumOptions:e.enumOptions}}s(Mv,"shapeOf");function E0(e){let n=new Map,t=[],r=s(o=>{o.fields.forEach(a=>n.set(a.key,Mv(a))),o.groups?.forEach(a=>a.fields.forEach(l=>n.set(l.key,Mv(l)))),o.repeated?.forEach(a=>t.push({key:a.key,itemTemplate:a.itemTemplate,effects:a.effects??[]})),o.subsections?.forEach(r)},"visit");e.sections.forEach(r);let i=[{pathPrefix:"",effects:e.effects??[],shapes:n}];for(let o of t){let a=new Map(n);o.itemTemplate.forEach(l=>a.set(`$item.${l.key}`,Mv(l))),i.push({pathPrefix:`repeated '${o.key}'.`,effects:o.effects,shapes:a})}return i}s(E0,"fieldMapScopes");function t5(e){let n=new Set,t=s(r=>{r.computed?.forEach(i=>n.add(i.key)),r.subsections?.forEach(t)},"visit");return e.sections.forEach(t),n}s(t5,"computedKeysOf");function T0(e){let n=[],t=t5(e);for(let r of E0(e))r.effects.forEach((i,o)=>{if(i.kind!=="fieldMap")return;let a=new Map;i.mappings.forEach((l,d)=>{let c=`${r.pathPrefix}effects[${o}].mappings[${d}]`;t.has(l.from)&&n.push({severity:"error",path:`${c}.from`,code:"fieldmap.computed-source",message:`Effect '${i.id}' fieldMap '${l.from}' \u2192 '${l.to}': '${l.from}' is a computed field. Its value is derived, never stored, and would never reach the party.`});let u=a.get(l.to);u!==void 0&&u!==l.from?n.push({severity:"error",path:`${c}.to`,code:"fieldmap.duplicate-target",message:`Effect '${i.id}' maps both '${u}' and '${l.from}' onto custom field '${l.to}'. One party field holds one value \u2014 the write would keep one and drop the other.`}):a.set(l.to,l.from)})});return n}s(T0,"validateFieldMapSources");function $0(e){let n=[],t=new Set;for(let o of E0(e))for(let a of o.effects)if(a.kind==="fieldMap")for(let l of a.mappings)t.add(l.from);let r=s((o,a)=>{let l=a.some(d=>t.has(d));o.kind==="cf_value"&&!l?n.push({severity:"error",path:`field '${o.key}'`,code:"persist.cf-unmapped",message:`Field '${o.key}' declares kind 'cf_value' but is not the source of any fieldMap mapping. Either wire a fieldMap ('${o.key}' \u2192 a custom-field key) or set kind: 'control'.`}):o.kind==="control"&&l&&n.push({severity:"error",path:`field '${o.key}'`,code:"persist.control-mapped",message:`Field '${o.key}' declares kind 'control' but is used as a fieldMap source, which would persist it. Set kind: 'cf_value', or remove the fieldMap mapping (a control field may still feed OutcomeDef.output.fields).`})},"check"),i=s(o=>{o.fields.forEach(a=>r(a,[a.key])),o.groups?.forEach(a=>a.fields.forEach(l=>r(l,[l.key]))),o.repeated?.forEach(a=>a.itemTemplate.forEach(l=>r(l,[`$item.${l.key}`,l.key]))),o.subsections?.forEach(i)},"visit");return e.sections.forEach(i),n}s($0,"validateFieldPersistence");var r5="$";function i5(e){return typeof e=="string"&&e.startsWith(r5)}s(i5,"isRef");function Nm(e){return e.slice(1)}s(Nm,"stripRef");function*o5(e){switch(e.kind){case"relationship":if(yield e.from,yield e.to,e.meta)for(let n of Object.values(e.meta))yield n;return;case"fieldMap":yield e.target;return;case"shareValue":yield e.from,yield e.to;return;case"person":case"organization":return}}s(o5,"refSlots");function s5(e){let n=new Set;for(let t of o5(e))i5(t)&&n.add(Nm(t));return[...n]}s(s5,"collectRefs");function a5(e){let n=new Set(e.map(o=>o.id)),t=new Map,r=new Map,i=new Map;for(let o of e)i.set(o.id,o),t.set(o.id,[]),r.set(o.id,[]);for(let o of e)for(let a of s5(o))n.has(a)&&(t.get(o.id).push(a),r.get(a).push(o.id));for(let o of e){if(o.kind!=="shareValue")continue;let a=Nm(o.from);for(let l of e)l.id===o.id||!(l.kind==="fieldMap"&&Nm(l.target)===a||l.kind==="shareValue"&&Nm(l.to)===a)||t.get(o.id).includes(l.id)||(t.get(o.id).push(l.id),r.get(l.id).push(o.id))}return{refsOf:t,successors:r,byId:i}}s(a5,"buildAdjacency");function R0(e){let{refsOf:n}=a5(e),r=Xf(e.map(i=>i.id),i=>(n.get(i)??[]).map(o=>({target:o,edge:null})))[0];return r===void 0?{hasCycle:!1}:{hasCycle:!0,cycle:r.cycle}}s(R0,"detectCycle");function I0(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}s(I0,"escapeRegExp");function Wi(e){return new RegExp(`^${I0(e)}\\[(\\d+)\\]\\.(.+)$`)}s(Wi,"repeatedRowKeyPattern");function qv(e,n){let t=Wi(n),r=0;for(let i of Object.keys(e)){let o=i.match(t);if(!o)continue;let a=Number(o[1]);Number.isInteger(a)&&a+1>r&&(r=a+1)}return r}s(qv,"countRepeatedRows");function O0(e,n,t){let r=Wi(n);for(let[i,o]of Object.entries(e)){let a=i.match(r);if(!(!a||Number(a[1])!==t)&&o!=null&&!(typeof o=="string"&&o.trim()==="")&&!(Array.isArray(o)&&o.length===0))return!0}return!1}s(O0,"repeatedRowHasData");function P0(e){return e.endsWith(".count")?e.slice(0,-6):e}s(P0,"readKeyOf");function Kv(e){return{sections:e,fields:[]}}s(Kv,"hiddenSectionsOnly");function N0(e,n,t){for(let r of e.fields)n.add(r.key);for(let r of e.groups??[])for(let i of r.fields)n.add(i.key);for(let r of e.computed??[])n.add(r.key);for(let r of e.repeated??[])t.add(r.key);for(let r of e.subsections??[])N0(r,n,t)}s(N0,"collectKeys");function _0(e){let n=[],t=s(r=>{if(r.visibleTo!==void 0){let i=new Set,o=new Set;N0(r,i,o),n.push({sectionId:r.id,label:r.label,visibleTo:r.visibleTo,fieldKeys:i,repeatedKeys:o,rowKeyPatterns:[...o].map(Wi)});return}for(let i of r.subsections??[])t(i)},"visit");for(let r of e.sections)t(r);return n}s(_0,"restrictedSectionsOf");function C0(e,n){return n.fieldKeys.has(e)||n.repeatedKeys.has(e)?!0:n.rowKeyPatterns.some(t=>t.test(e))}s(C0,"matchesKey");function l5(e,n){return n.find(t=>C0(e,t))??null}s(l5,"hiddenSectionOfKey");function d5(e,n){for(let t=e;;){if(C0(t,n))return!0;let r=t.lastIndexOf(".");if(r===-1)return!1;t=t.slice(0,r)}}s(d5,"fieldOwnsKey");function c5(e,n){return n.find(t=>d5(e,t))??null}s(c5,"restrictedFieldOfKey");function u5(e,n){let t=l5(e,n.sections);if(t!==null)return{kind:"section",section:t};let r=c5(e,n.fields);return r===null?null:{kind:"field",field:r}}s(u5,"hiddenOwnerOfKey");function _m(e,n){return u5(e,n)!==null}s(_m,"isKeyHidden");function f5(e,n,t,r,i){let o=[];r&&o.push({severity:"error",path:t,code:"section.visibleTo-nested",message:{de:`Abschnitt '${e}' liegt in einem Abschnitt mit eingeschr\xE4nkter Sichtbarkeit (visibleTo) und darf selbst keine tragen.`,en:`Section '${e}' sits inside a section with restricted visibility (visibleTo) and may not carry one itself.`}});let a=s(l=>typeof l!="string"||l.trim()==="","isBlank");if((n.length===0||n.some(a)||new Set(n).size!==n.length)&&o.push({severity:"error",path:t,code:"section.visibleTo-invalid",message:{de:`Abschnitt '${e}': visibleTo braucht mindestens ein Team, ohne leere oder doppelte Eintr\xE4ge.`,en:`Section '${e}': visibleTo needs at least one team, with no blank or repeated entries.`}}),i===void 0)return o;for(let l of n)a(l)||i.has(l)||o.push({severity:"error",path:t,code:"section.visibleTo-unknown",message:{de:`Abschnitt '${e}': '${l}' ist weder ein Team noch eine Rechtegruppe dieser Schule.`,en:`Section '${e}': '${l}' is neither a team nor a permission group of this school.`}});return o}s(f5,"visibleToListIssues");function D0(e,n,t){let r=[],i=s((c,u,p)=>{let m=c.visibleTo;m!==void 0&&r.push(...f5(c.id,m,`${u}.visibleTo`,p,t));let y=p||m!==void 0;if(y){let k=[...c.fields,...(c.groups??[]).flatMap(g=>g.fields),...(c.repeated??[]).flatMap(g=>g.itemTemplate)];for(let g of k)g.kind==="cf_value"&&r.push({severity:"error",path:`${u}.fields`,code:"section.visibleTo-party",message:{de:`Feld '${g.key}' wird in die Personendaten \xFCbernommen und kann deshalb nicht in einem Abschnitt mit eingeschr\xE4nkter Sichtbarkeit (visibleTo) liegen.`,en:`Field '${g.key}' is carried into the person record and therefore cannot sit in a section with restricted visibility (visibleTo).`}})}(c.subsections??[]).forEach((k,g)=>i(k,`${u}.subsections[${g}]`,y))},"visitRaw");e.sections.forEach((c,u)=>i(c,`sections[${u}]`,!1));let o=_0(e);if(o.length===0)return r;let a=s((c,u,p)=>{if(c===void 0)return;let m=Kv(p);for(let y of xn(c)){let k=P0(y);(_m(y,m)||_m(k,m))&&r.push({severity:"error",path:u,code:"section.visibleTo-read-outside",message:{de:`${u} liest '${y}' aus einem Abschnitt mit eingeschr\xE4nkter Sichtbarkeit (visibleTo) \u2014 wer den Abschnitt nicht sieht, bek\xE4me hier ein anderes Ergebnis.`,en:`${u} reads '${y}' from a section with restricted visibility (visibleTo) \u2014 whoever cannot see the section would get a different result here.`}})}},"checkAst"),l=s((c,u,p)=>{a(c.visibleIf,`${u}.visibleIf`,p),a(c.requiredIf,`${u}.requiredIf`,p),a(c.disabledIf,`${u}.disabledIf`,p),a(c.defaultValue,`${u}.defaultValue`,p),c.sameAs!==void 0&&_m(c.sameAs.source,Kv(p))&&r.push({severity:"error",path:`${u}.sameAs`,code:"section.visibleTo-read-outside",message:{de:`${u} \xFCbernimmt '${c.sameAs.source}' aus einem Abschnitt mit eingeschr\xE4nkter Sichtbarkeit (visibleTo).`,en:`${u} copies '${c.sameAs.source}' from a section with restricted visibility (visibleTo).`}})},"checkField"),d=s((c,u,p)=>{let m=c.visibleTo!==void 0?c.id:p,y=o.filter(k=>k.sectionId!==m);a(c.visibleIf,`${u}.visibleIf`,c.visibleTo!==void 0?o:y),c.fields.forEach((k,g)=>l(k,`${u}.fields[${g}]`,y)),c.groups?.forEach((k,g)=>{a(k.visibleIf,`${u}.groups[${g}].visibleIf`,y),k.fields.forEach((v,E)=>l(v,`${u}.groups[${g}].fields[${E}]`,y))}),c.repeated?.forEach((k,g)=>{a(k.itemVisibleIf,`${u}.repeated[${g}].itemVisibleIf`,y),k.itemTemplate.forEach((v,E)=>l(v,`${u}.repeated[${g}].itemTemplate[${E}]`,y))}),c.computed?.forEach((k,g)=>a(k.expression,`${u}.computed[${g}]`,y)),c.subsections?.forEach((k,g)=>d(k,`${u}.subsections[${g}]`,m))},"visitCompiled");return n.sections.forEach((c,u)=>d(c,`sections[${u}]`,null)),r}s(D0,"sectionVisibilityIssues");var Ur="#";var F0=s(e=>{let n=wk.find(t=>t.systemColumn===e);return n===void 0&&F(`[personName] no system field backs ${e}`),n.key},"keyOfColumn"),vr={firstName:F0("persons.firstName"),lastName:F0("persons.lastName")};function L0(e,n){let t={firstName:[],lastName:[]},r=`$${e}`;for(let i of n)if(!(i.kind!=="fieldMap"||i.target!==r))for(let{from:o,to:a}of i.mappings??[])a===vr.firstName?t.firstName.push(o):a===vr.lastName&&t.lastName.push(o);return t}s(L0,"personNameKeys");function M0(e){return[...e.firstName,...e.lastName]}s(M0,"personNameKeyList");function q0(e){return e.firstName.length>0||e.lastName.length>0}s(q0,"hasPersonName");function wa(e,n=[],t){let r=[];return e.forEach((i,o)=>{let a=[...n,o];r.push({section:i,path:a,parentId:t});for(let l of wa(i.subsections??[],a,i.id))r.push(l)}),r}s(wa,"walkSections");function p5(e,n){for(let t of e.fields)if(t.key===n)return t;for(let t of e.groups??[])for(let r of t.fields)if(r.key===n)return r;for(let t of e.repeated??[])for(let r of t.itemTemplate)if(r.key===n)return r;return null}s(p5,"findFieldInSection");function K0(e,n){for(let t of wa(e.sections)){let r=p5(t.section,n);if(r)return{section:t.section,field:r}}return null}s(K0,"findField");var m5=["Baby","BookOpen","BriefcaseBusiness","Building2","FileText","GraduationCap","HeartHandshake","Scale","UserCheck","UserRound","Users","UsersRound"],h5=["blue","rose","amber","violet","teal","emerald","slate"];function j0(e){return m5.includes(e)}s(j0,"isBucketIconName");function B0(e){return h5.includes(e)}s(B0,"isBucketColorName");var g5="__clear__";function V0(e){return e===""?"empty":e===g5?"reserved":null}s(V0,"selectOptionValueDefect");var jv=tD.docRef.allowedMime;function H0(e,n={}){let t=Zs(e).compiled,r=[],i=new Set,o=new Map,a=new Set,l=new Set,d=new Set,c=new Map,u=new Map;function p(O,N){if(i.has(O))return;i.add(O);let K=o.get(O.id);K&&K!==O?r.push({severity:"error",path:`sections[${N.join(".")}]`,code:"duplicate.section-id",message:{de:`Abschnitts-ID '${O.id}' ist mehrfach deklariert.`,en:`Section id '${O.id}' is declared more than once.`}}):o.set(O.id,O);let C=`sections[${N.join(".")}]`;O.fields.forEach((G,ae)=>{ka(a,G.key,`${C}.fields[${ae}]`,"duplicate.field-key",r),l.add(G.key),u.set(G.key,G),c.set(G.key,Vv(G)),G.externalFlag&&(G.type!=="boolean"&&r.push({severity:"error",path:`${C}.fields[${ae}]`,code:"flag.not-boolean",message:{de:`Externes Flag '${G.key}' muss den Typ 'boolean' haben (ist '${G.type}').`,en:`External flag '${G.key}' must be type 'boolean' (got '${G.type}').`}}),G.reviewRequired!==void 0&&r.push({severity:"error",path:`${C}.fields[${ae}]`,code:"review.on-flag",message:{de:`Externes Flag '${G.key}' ist als pr\xFCfpflichtig markiert \u2014 ein Flag setzt der Prozess, die Familie reicht nichts ein, was jemand pr\xFCfen k\xF6nnte.`,en:`External flag '${G.key}' is marked as requiring review \u2014 the process sets a flag, the family hands in nothing anyone could review.`}}),G.notice!==void 0&&r.push({severity:"error",path:`${C}.fields[${ae}]`,code:"config.notice-on-flag",message:{de:`Externes Flag '${G.key}' tr\xE4gt einen Hinweis (notice) \u2014 ein Flag wird der Familie nie angezeigt, also auch sein Hinweis nicht.`,en:`External flag '${G.key}' carries a notice \u2014 a flag is never shown to the family, so neither is its notice.`}}),G.defaultValue==null&&r.push({severity:"error",path:`${C}.fields[${ae}]`,code:"flag.missing-default",message:{de:`Externes Flag '${G.key}' muss einen defaultValue deklarieren (z. B. "false"), damit es standardm\xE4\xDFig verborgen ist.`,en:`External flag '${G.key}' must declare a defaultValue (e.g. "false") so it is hidden by default.`}})),r.push(...G0(G,`${C}.fields[${ae}]`)),r.push(...U0(G,`${C}.fields[${ae}]`))}),O.groups?.forEach((G,ae)=>{G.fields.forEach((ce,Ce)=>{ka(a,ce.key,`${C}.groups[${ae}].fields[${Ce}]`,"duplicate.field-key",r),l.add(ce.key),u.set(ce.key,ce),c.set(ce.key,Vv(ce)),ce.externalFlag&&r.push({severity:"error",path:`${C}.groups[${ae}].fields[${Ce}]`,code:"flag.invalid-location",message:{de:`Externes Flag '${ce.key}' muss ein direktes Abschnittsfeld sein, kein Gruppenfeld.`,en:`External flag '${ce.key}' must be a direct section field, not a group field.`}}),r.push(...G0(ce,`${C}.groups[${ae}].fields[${Ce}]`)),r.push(...U0(ce,`${C}.groups[${ae}].fields[${Ce}]`))})}),O.repeated?.forEach((G,ae)=>{G.itemTemplate.forEach((ce,Ce)=>{ka(a,ce.key,`${C}.repeated[${ae}].itemTemplate[${Ce}]`,"duplicate.field-key",r),c.set(ce.key,Vv(ce)),ce.externalFlag&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"flag.invalid-location",message:{de:`Externes Flag '${ce.key}' muss ein direktes Abschnittsfeld sein, kein Feld einer Wiederholung.`,en:`External flag '${ce.key}' must be a direct section field, not a repeated item field.`}}),ce.export&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"export.in-repeated",message:{de:`Feld '${ce.key}' deklariert export in einem itemTemplate einer Wiederholung \u2014 ein zusammengesetztes Blatt gilt je Bewerbung, ein Zeilenfeld je Zeile.`,en:`Field '${ce.key}' declares export inside a repeated itemTemplate \u2014 a compound leaf is per-application, a row field is per-row.`}}),ce.sameAs&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"config.sameas-in-repeated",message:{de:`Feld '${ce.key}' deklariert sameAs in einem itemTemplate einer Wiederholung \u2014 nicht unterst\xFCtzt.`,en:`Field '${ce.key}' declares sameAs inside a repeated itemTemplate \u2014 not supported.`}}),ce.reviewRequired!==void 0&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"review.in-repeated",message:{de:`Feld '${ce.key}' ist in einem itemTemplate einer Wiederholung als pr\xFCfpflichtig markiert \u2014 ein Zeilenfeld hat je Zeile einen Wert, kein Feld der Bewerbung, das man einmal abhaken k\xF6nnte.`,en:`Field '${ce.key}' is marked as requiring review inside a repeated itemTemplate \u2014 a row field has one value per row, no field of the application to tick once.`}}),ce.notice!==void 0&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"config.notice-in-repeated",message:{de:`Feld '${ce.key}' tr\xE4gt einen Hinweis (notice) in einem itemTemplate einer Wiederholung \u2014 dort wird er nicht angezeigt. Den Hinweis an den Abschnitt setzen.`,en:`Field '${ce.key}' carries a notice inside a repeated itemTemplate \u2014 it is not shown there. Put the notice on the section.`}}),ce.type==="docRef"&&ce.docRefConstraints?.multiple===!0&&r.push({severity:"error",path:`${C}.repeated[${ae}].itemTemplate[${Ce}]`,code:"config.docref-multiple-in-repeated",message:{de:`Feld '${ce.key}' setzt docRefConstraints.multiple in einem itemTemplate einer Wiederholung \u2014 ein Mehrfach-Upload ist nur als Abschnitts- oder Gruppenfeld m\xF6glich.`,en:`Field '${ce.key}' sets docRefConstraints.multiple inside a repeated itemTemplate \u2014 a multi-file upload is supported only as a section or group field.`}})})}),O.computed?.forEach(G=>{d.add(G.key),ka(a,G.key,`${C}.computed[${G.key}]`,"duplicate.field-key",r),G.exportType==="consent"&&r.push({severity:"error",path:`${C}.computed[${G.key}]`,code:"config.consent-computed",message:{de:`Berechnetes Feld '${G.key}' ist als Zustimmung (consent) typisiert \u2014 eine Zustimmung gibt die Person selbst, keine Berechnung. exportType 'boolean' verwenden.`,en:`Computed '${G.key}' is typed as a consent \u2014 a consent is given by the person, never computed. Use exportType 'boolean'.`}}),G.export===!0&&G.exportType===void 0&&r.push({severity:"error",path:`${C}.computed[${G.key}]`,code:"export.computed-untyped",message:{de:`Berechnetes Feld '${G.key}' wird ohne exportType exportiert \u2014 string | number | boolean | date angeben.`,en:`Computed '${G.key}' is exported without an exportType \u2014 declare string | number | boolean | date.`}})}),O.subsections?.forEach((G,ae)=>p(G,[...N,ae]))}s(p,"visitRawSection"),e.sections.forEach((O,N)=>p(O,[N]));let m=new Set;t.effects.forEach((O,N)=>{ka(m,O.id,`effects[${N}]`,"duplicate.effect-id",r)});let y=new Set;t.outcomes.forEach((O,N)=>{ka(y,O.id,`outcomes[${N}]`,"duplicate.outcome-id",r)}),t.outcomes.forEach((O,N)=>{O.output.effectRefs?.forEach((K,C)=>{m.has(K.effect)||r.push({severity:"error",path:`outcomes[${N}].output.effectRefs[${C}]`,code:"ref.unknown-effect",message:{de:`Ergebnis '${O.id}' verweist auf den unbekannten Effekt '${K.effect}'.`,en:`Outcome '${O.id}' references unknown effect '${K.effect}'.`}})})}),t.outcomes.forEach((O,N)=>{O.output.fields?.forEach((K,C)=>{K0(t,K.path)||r.push({severity:"error",path:`outcomes[${N}].output.fields[${C}]`,code:"ref.unknown-field",message:{de:`Ergebnis '${O.id}' verweist auf das unbekannte Feld '${K.path}'.`,en:`Outcome '${O.id}' references unknown field '${K.path}'.`}})})});let k=new Set;for(let O of wa(t.sections))for(let N of O.section.repeated??[])k.add(`${N.key}.count`);for(let O of k)(a.has(O)||d.has(O))&&r.push({severity:"error",path:"sections",code:"duplicate.field-key",message:{de:`'${O}' ist zugleich ein deklarierter Schl\xFCssel und die abgeleitete Zeilenzahl einer Wiederholung \u2014 der abgeleitete Wert w\xFCrde stillschweigend gewinnen.`,en:`'${O}' is both a declared key and the derived row count of a repeated group \u2014 the derived value would silently win.`}});let g={known:new Set([...a,...d,...k]),declaredContext:new Set(e.env??[]),stageKeys:n.stageKeys};r.push(...gN(e)),r.push(...D0(e,t,n.visibleToKeys)),r.push(...QN(e)),r.push(...pN(e,n.stageKeys));for(let O of wa(t.sections)){let N=O.section,K=`sections[${O.path.join(".")}]`;N.visibleIf&&(xr(N.visibleIf,`${K}.visibleIf`,g,!1,r),ba(N.visibleIf,`${K}.visibleIf`,c,r)),N.fields.forEach((C,G)=>Bv(C,`${K}.fields[${G}]`,g,!1,c,r)),N.groups?.forEach((C,G)=>{C.visibleIf&&(xr(C.visibleIf,`${K}.groups[${G}].visibleIf`,g,!1,r),ba(C.visibleIf,`${K}.groups[${G}].visibleIf`,c,r)),C.fields.forEach((ae,ce)=>Bv(ae,`${K}.groups[${G}].fields[${ce}]`,g,!1,c,r))}),N.repeated?.forEach((C,G)=>{C.itemVisibleIf&&(xr(C.itemVisibleIf,`${K}.repeated[${G}].itemVisibleIf`,g,!0,r),ba(C.itemVisibleIf,`${K}.repeated[${G}].itemVisibleIf`,c,r)),C.itemTemplate.forEach((ae,ce)=>Bv(ae,`${K}.repeated[${G}].itemTemplate[${ce}]`,g,!0,c,r)),C.effects?.forEach((ae,ce)=>{ae.when&&xr(ae.when,`${K}.repeated[${G}].effects[${ce}].when`,g,!0,r)})}),N.computed?.forEach((C,G)=>xr(C.expression,`${K}.computed[${G}].expression`,g,!1,r))}t.effects.forEach((O,N)=>{O.when&&xr(O.when,`effects[${N}].when`,g,!1,r)}),t.outcomes.forEach((O,N)=>{xr(O.when,`outcomes[${N}].when`,g,!1,r)});let v=new Set(t.outcomes.map(O=>O.id));function E(O,N){O.requiredFor&&O.requiredFor.forEach((K,C)=>{v.has(K)||r.push({severity:"error",path:`${N}.requiredFor[${C}]`,code:"ref.unknown-required-for-outcome",message:{de:`Feld "${O.key}": requiredFor verweist auf das unbekannte Ergebnis "${K}"`,en:`field "${O.key}": requiredFor references unknown outcome "${K}"`}})})}s(E,"checkRequiredFor");for(let O of wa(t.sections)){let N=O.section,K=`sections[${O.path.join(".")}]`;N.fields.forEach((C,G)=>E(C,`${K}.fields[${G}]`)),N.groups?.forEach((C,G)=>{C.fields.forEach((ae,ce)=>E(ae,`${K}.groups[${G}].fields[${ce}]`))}),N.repeated?.forEach((C,G)=>{C.itemTemplate.forEach((ae,ce)=>E(ae,`${K}.repeated[${G}].itemTemplate[${ce}]`))})}function A(O,N){let K=s((C,G)=>{let ae=(C.type==="docRef"?C.docRefConstraints?.mimeType??[]:[]).filter(Ae=>!jv.includes(Ae));ae.length>0&&r.push({severity:"error",path:G,code:"config.docref-type-outside-ceiling",message:{de:`Feld '${C.key}' erlaubt ${ae.map(Ae=>`'${Ae}'`).join(", ")} \u2014 kein Dokument-Upload akzeptiert diesen Typ (erlaubt: ${jv.join(", ")}).`,en:`Field '${C.key}' allows ${ae.map(Ae=>`'${Ae}'`).join(", ")} \u2014 no document upload accepts that type (allowed: ${jv.join(", ")}).`}});let ce=C.type==="docRef"?C.docRefConstraints?.minFiles:void 0;if(ce!==void 0){let Ae=C.docRefConstraints?.multiple===!0,hn=typeof ce=="number"&&Number.isInteger(ce)&&ce>=2;(!Ae||!hn)&&r.push({severity:"error",path:G,code:"config.docref-min-files",message:Ae?{de:`Feld '${C.key}' setzt docRefConstraints.minFiles auf ${JSON.stringify(ce)} \u2014 erlaubt ist eine ganze Zahl ab 2.`,en:`Field '${C.key}' sets docRefConstraints.minFiles to ${JSON.stringify(ce)} \u2014 it must be a whole number of at least 2.`}:{de:`Feld '${C.key}' setzt docRefConstraints.minFiles ohne docRefConstraints.multiple: true \u2014 eine Mindestanzahl gibt es nur bei einem Mehrfach-Upload.`,en:`Field '${C.key}' sets docRefConstraints.minFiles without docRefConstraints.multiple: true \u2014 a minimum count exists only on a multi-file upload.`}})}C.multiple===!0&&C.type!=="enum"&&r.push({severity:"error",path:G,code:"config.multiple-non-enum",message:{de:`Feld '${C.key}' setzt multiple: true, hat aber den Typ '${C.type}' \u2014 nur 'enum' unterst\xFCtzt Mehrfachauswahl.`+(C.type==="docRef"?" F\xFCr mehrere Dateien docRefConstraints.multiple: true verwenden.":""),en:`Field '${C.key}' sets multiple: true but is type '${C.type}' \u2014 only 'enum' supports multi-select.`+(C.type==="docRef"?" For several files use docRefConstraints.multiple: true.":"")}}),C.presentation==="yesNo"&&C.type!=="boolean"&&r.push({severity:"error",path:G,code:"config.yesno-non-boolean",message:{de:`Feld '${C.key}' setzt presentation: 'yesNo', hat aber den Typ '${C.type}' \u2014 nur 'boolean'-Felder lassen sich als Ja | Nein-Antwort darstellen.`,en:`Field '${C.key}' sets presentation: 'yesNo' but is type '${C.type}' \u2014 only 'boolean' fields can be drawn as the Yes | No answer.`}}),C.presentation==="yesNo"&&C.defaultValue!=null&&r.push({severity:"error",path:G,code:"config.yesno-default",message:{de:`Feld '${C.key}' ist eine Ja | Nein-Frage (presentation: 'yesNo') mit einem defaultValue \u2014 die Familie muss die Antwort selbst w\xE4hlen. Den defaultValue entfernen.`,en:`Field '${C.key}' is a Yes | No question (presentation: 'yesNo') with a defaultValue \u2014 the family must choose the answer themselves. Remove the defaultValue.`}}),r.push(...w5(C,G)),typeof C.minSelections=="number"&&typeof C.maxSelections=="number"&&C.minSelections>C.maxSelections&&r.push({severity:"error",path:G,code:"config.min-gt-max-selections",message:{de:`Feld '${C.key}' hat minSelections (${C.minSelections}) > maxSelections (${C.maxSelections}).`,en:`Field '${C.key}' has minSelections (${C.minSelections}) > maxSelections (${C.maxSelections}).`}});let Ce=C.enumRef;Ce!==void 0&&r.push({severity:"error",path:`${G}.enumRef`,code:"config.enum-ref-retired",message:{de:`Feld '${C.key}' nennt den entfernten Options-Katalog (enumRef '${String(Ce)}'). Die Optionen im Formular angeben (enumOptions + enumOptionLabels) oder eine Liste des Mandanten binden (enumListKey).`,en:`Field '${C.key}' names the removed option catalog (enumRef '${String(Ce)}'). Author the options in the form (enumOptions + enumOptionLabels) or bind a tenant list (enumListKey).`}}),(C.enumOptions??[]).forEach((Ae,hn)=>{let Je=V0(Ae);Je!==null&&r.push({severity:"error",path:`${G}.enumOptions[${hn}]`,code:"config.enum-option-value",message:{de:Je==="empty"?`Feld '${C.key}' hat einen leeren Enum-Optionswert \u2014 das Steuerelement kann ihn nicht tragen. Der Option einen Wert geben oder sie streichen: Ein Feld, das unbeantwortet bleiben darf, bietet bereits eine eigene Zeile zum Leeren.`:`Feld '${C.key}' hat den Enum-Optionswert '${Ae}', den die Einzelauswahl f\xFCr ihre Zeile zum Leeren reserviert. Die Option umbenennen.`,en:Je==="empty"?`Field '${C.key}' has an empty enum option value \u2014 the control cannot carry it. Give the option a value, or drop it: a field that may be left unanswered already offers its own clear row.`:`Field '${C.key}' has the enum option value '${Ae}', which the single select reserves for its clear row. Rename the option.`}})}),(C.attachments??[]).forEach((Ae,hn)=>{if("storageId"in Ae){r.push({severity:"error",path:`${G}.attachments[${hn}]`,code:"config.attachment-source",message:{de:`Anhang des Felds '${C.key}' tr\xE4gt eine rohe 'storageId' \u2014 Anh\xE4nge nennen eine Bibliotheksdatei jetzt per 'fileKey' (plexus-cli files put, dann field attach --file-key).`,en:`Field '${C.key}' attachment carries a raw 'storageId' \u2014 attachments name a library file by 'fileKey' now (plexus-cli files put, then field attach --file-key).`}});return}let Je=Ae.fileKey!==void 0&&Ae.fileKey!=="",An=Ae.url!==void 0&&Ae.url!=="";Je===An&&r.push({severity:"error",path:`${G}.attachments[${hn}]`,code:"config.attachment-source",message:{de:`Anhang des Felds '${C.key}' muss genau eines von 'fileKey' oder 'url' setzen (hat ${Je&&An?"beide":"keines"}).`,en:`Field '${C.key}' attachment must set exactly one of 'fileKey' or 'url' (got ${Je&&An?"both":"neither"}).`}}),Ae.renderAs==="inlineLink"&&Ae.label===void 0&&r.push({severity:"error",path:`${G}.attachments[${hn}]`,code:"config.attachment-inline-link-label",message:{de:`inlineLink-Anhang des Felds '${C.key}' braucht ein 'label' \u2014 die verlinkte Wendung im Feldlabel.`,en:`Field '${C.key}' inlineLink attachment needs a 'label' \u2014 the linked phrase shown in the field label.`}})})},"considerField");O.fields.forEach((C,G)=>K(C,`${N}.fields[${G}]`)),O.groups?.forEach((C,G)=>{C.fields.forEach((ae,ce)=>K(ae,`${N}.groups[${G}].fields[${ce}]`))}),O.repeated?.forEach((C,G)=>{C.itemTemplate.forEach((ae,ce)=>{let Ce=`${N}.repeated[${G}].itemTemplate[${ce}]`;K(ae,Ce),ae.type==="consent"&&r.push({severity:"error",path:Ce,code:"config.consent-in-repeated",message:{de:`Feld '${ae.key}' ist eine Zustimmung in einem Wiederholungsblock \u2014 Zustimmungen stehen nur als Feld eines Abschnitts oder einer Gruppe.`,en:`Field '${ae.key}' is a consent inside a repeated block \u2014 a consent stands only as a field of a section or a group.`}})})}),O.subsections?.forEach((C,G)=>A(C,`${N}.subsections[${G}]`))}s(A,"visitFieldConfig"),e.sections.forEach((O,N)=>A(O,`sections[${N}]`)),e.effects.forEach((O,N)=>{if(O.kind==="person"){r.push(...Y0(O,e.effects,`effects[${N}]`,K=>l.has(K)));return}O.kind==="organization"&&O.nameFrom?.forEach((K,C)=>{l.has(K)||r.push({severity:"error",path:`effects[${N}].nameFrom[${C}]`,code:"ref.unknown-name-field",message:{de:`Effekt '${O.id}': nameFrom verweist auf das unbekannte Feld '${K}'.`,en:`Effect '${O.id}' nameFrom references unknown field '${K}'.`}})})});let I=s((O,N)=>{if(O.kind!=="person"&&O.kind!=="organization")return;let K=O.display;if(!K){r.push({severity:"error",path:`${N}.display`,code:"display.missing",message:{de:`Effekt '${O.id}' deklariert einen Partei-Bucket, aber kein display \u2014 Titel, Icon und Akzentfarbe der Partei w\xE4ren nicht aufl\xF6sbar.`,en:`Effect '${O.id}' declares a party bucket but no display \u2014 the party's title, icon and accent colour could not be resolved.`}});return}j0(K.icon)||r.push({severity:"error",path:`${N}.display.icon`,code:"display.unknown-icon",message:{de:`Effekt '${O.id}': display.icon '${K.icon}' ist kein bekanntes Bucket-Icon.`,en:`Effect '${O.id}' display.icon '${K.icon}' is not a known bucket icon.`}}),B0(K.color)||r.push({severity:"error",path:`${N}.display.color`,code:"display.unknown-color",message:{de:`Effekt '${O.id}': display.color '${K.color}' ist keine bekannte Bucket-Farbe.`,en:`Effect '${O.id}' display.color '${K.color}' is not a known bucket colour.`}})},"checkBucketDisplay");e.effects.forEach((O,N)=>I(O,`effects[${N}]`));let _=new Set,T=s(O=>{O.kind==="person"?_.add(O.bucket):O.kind==="organization"&&_.add(O.id.replace(/^o\./,""))},"declareBucket");e.effects.forEach(T);let b=new Set,R=s(O=>{for(let N of O)N.repeated?.forEach(K=>K.effects?.forEach(C=>T(C))),R(N.subsections??[])},"collectRepeatedBuckets");R(e.sections);let q=s((O,N)=>{_.size!==0&&O.forEach((K,C)=>{K.bucket===void 0||_.has(K.bucket)||r.push({severity:"error",path:`${N}[${C}].bucket`,code:"bucket.undeclared",message:{de:`Feld '${K.key}' geh\xF6rt zum Bucket '${K.bucket}', aber kein Person-/Organisations-Effekt deklariert ihn \u2014 das Feld geh\xF6rt zu keiner Partei.`,en:`Field '${K.key}' belongs to bucket '${K.bucket}', but no person/organization effect declares it \u2014 the field belongs to no party.`}})})},"checkFieldBuckets"),P=s((O,N)=>{if(b.has(O))return;b.add(O);let K=`sections[${N.join(".")}]`;q(O.fields,`${K}.fields`),O.groups?.forEach((C,G)=>q(C.fields,`${K}.groups[${G}].fields`)),O.repeated?.forEach((C,G)=>q(C.itemTemplate,`${K}.repeated[${G}].itemTemplate`)),O.subsections?.forEach((C,G)=>P(C,[...N,G]))},"visitBucketSection");e.sections.forEach((O,N)=>P(O,[N]));let J=e.effects.flatMap((O,N)=>O.kind==="person"&&O.subject===!0?[{e:O,i:N}]:[]);J.length>1&&J.slice(1).forEach(({e:O,i:N})=>{r.push({severity:"error",path:`effects[${N}].subject`,code:"subject.duplicate",message:{de:`Effekt '${O.id}' deklariert subject:true, aber '${J[0].e.id}' tut es bereits. Genau ein Bucket darf das Subjekt der Bewerbung sein.`,en:`Effect '${O.id}' declares subject:true, but '${J[0].e.id}' already does. Exactly one bucket may be the application subject.`}})}),e.effects.forEach((O,N)=>{if(!(O.kind!=="person"||O.nationalityFrom===void 0)){if(O.subject!==!0){r.push({severity:"error",path:`effects[${N}].nationalityFrom`,code:"nationality.not-subject",message:{de:`Effekt '${O.id}' deklariert nationalityFrom, ist aber nicht das Subjekt der Bewerbung \u2014 die Staatsangeh\xF6rigkeit wird nur f\xFCr das Subjekt der Bewerbung gelesen.`,en:`Effect '${O.id}' declares nationalityFrom but is not the application subject \u2014 nationality is read only for the application subject.`}});return}if(O.nationalityFrom.length===0){r.push({severity:"error",path:`effects[${N}].nationalityFrom`,code:"nationality.empty",message:{de:`Effekt '${O.id}' deklariert ein leeres nationalityFrom \u2014 weglassen oder mindestens ein Feld nennen.`,en:`Effect '${O.id}' declares an empty nationalityFrom \u2014 omit it or name at least one field.`}});return}O.nationalityFrom.forEach((K,C)=>{l.has(K)||r.push({severity:"error",path:`effects[${N}].nationalityFrom[${C}]`,code:"nationality.unknown-field",message:{de:`Effekt '${O.id}': nationalityFrom verweist auf das unbekannte Feld '${K}'.`,en:`Effect '${O.id}' nationalityFrom references unknown field '${K}'.`}})})}});let Y=e.effects.flatMap((O,N)=>O.kind==="person"&&O.contractParty!==void 0?[{e:O,i:N,decl:O.contractParty}]:[]);if(Y.length>0){let O=new Map;Y.forEach(({e:K,i:C})=>{let G=O.get(K.bucket);if(G===void 0){O.set(K.bucket,K.id);return}r.push({severity:"error",path:`effects[${C}].contractParty`,code:"contractParty.duplicate-bucket",message:{de:`Effekt '${K.id}' deklariert eine Vertragspartei auf Bucket '${K.bucket}', aber '${G}' tut es bereits. Ein Bucket ist h\xF6chstens eine Vertragspartei.`,en:`Effect '${K.id}' declares a contract party on bucket '${K.bucket}', but '${G}' already does. A bucket is at most one contract party.`}})});let N=Y.filter(({decl:K})=>K.role==="beneficiary");N.slice(1).forEach(({e:K,i:C})=>{r.push({severity:"error",path:`effects[${C}].contractParty.role`,code:"contractParty.duplicate-beneficiary",message:{de:`Effekt '${K.id}' deklariert contractParty.role 'beneficiary', aber '${N[0].e.id}' tut es bereits. Genau ein Bucket darf Leistungsempf\xE4nger sein.`,en:`Effect '${K.id}' declares contractParty.role 'beneficiary', but '${N[0].e.id}' already does. Exactly one bucket may be the beneficiary.`}})}),N.forEach(({e:K,i:C})=>{K.subject!==!0&&r.push({severity:"error",path:`effects[${C}].contractParty.role`,code:"contractParty.beneficiary-not-subject",message:{de:`Effekt '${K.id}' ist der Leistungsempf\xE4nger des Vertrags, aber nicht das Subjekt der Bewerbung. Leistungsempf\xE4nger und Subjekt der Bewerbung sind dieselbe Person \u2014 subject:true auf '${K.id}' setzen.`,en:`Effect '${K.id}' is the contract beneficiary but not the application subject. The beneficiary and the application subject are the same person \u2014 set subject:true on '${K.id}'.`}})}),J.forEach(({e:K,i:C})=>{let G=K.contractParty?.role;G!==void 0&&G!=="beneficiary"&&r.push({severity:"error",path:`effects[${C}].contractParty.role`,code:"contractParty.subject-role-mismatch",message:{de:`Effekt '${K.id}' ist das Subjekt der Bewerbung, deklariert aber contractParty.role '${G}'. Das Subjekt der Bewerbung ist der Leistungsempf\xE4nger des Vertrags.`,en:`Effect '${K.id}' is the application subject but declares contractParty.role '${G}'. The application subject is the contract beneficiary.`}})}),Y.some(({decl:K})=>K.signs===!0)||r.push({severity:"error",path:"effects",code:"contractParty.no-signer",message:{de:"Das Formular deklariert Vertragsparteien, aber keine unterschreibt (contractParty.signs). Ein Vertrag ohne Unterzeichner kann nicht erzeugt werden.",en:"The form declares contract parties, but none signs (contractParty.signs). A contract without a signatory cannot be generated."}})}e.effects.forEach((O,N)=>{O.kind==="fieldMap"&&O.mappings.forEach((K,C)=>{a.has(K.from)||r.push({severity:"error",path:`effects[${N}].mappings[${C}].from`,code:"ref.unknown-fieldmap-from",message:{de:`Effekt '${O.id}': fieldMap from '${K.from}' verweist auf ein unbekanntes Feld.`,en:`Effect '${O.id}' fieldMap from '${K.from}' references unknown field.`}})})});for(let[O,N]of u){if(!N.sameAs)continue;let K=`fields[${O}].sameAs`,C=u.get(N.sameAs.source);C===void 0||N.sameAs.source===O?r.push({severity:"error",path:`${K}.source`,code:"ref.unknown-sameas-source",message:{de:N.sameAs.source===O?`Feld '${O}': sameAs.source verweist auf sich selbst.`:`Feld '${O}': sameAs.source verweist auf das unbekannte Feld '${N.sameAs.source}' (muss ein Abschnitts- oder Gruppenfeld sein).`,en:N.sameAs.source===O?`Field '${O}' sameAs.source references itself.`:`Field '${O}' sameAs.source references unknown field '${N.sameAs.source}' (must be a top-level or group field).`}}):C.type!==N.type?r.push({severity:"error",path:`${K}.source`,code:"ref.unknown-sameas-source",message:{de:`Feld '${O}' (${N.type}): sameAs.source '${N.sameAs.source}' hat einen anderen Typ (${C.type}) \u2014 die Spiegelung muss formgleich sein.`,en:`Field '${O}' (${N.type}) sameAs.source '${N.sameAs.source}' has a different type (${C.type}) \u2014 the mirror must be shape-identical.`}}):C.sameAs&&r.push({severity:"error",path:`${K}.source`,code:"ref.unknown-sameas-source",message:{de:`Feld '${O}': sameAs.source '${N.sameAs.source}' deklariert selbst sameAs \u2014 Spiegelketten werden nicht unterst\xFCtzt.`,en:`Field '${O}' sameAs.source '${N.sameAs.source}' itself declares sameAs \u2014 mirror chains are not supported.`}});let G=u.get(N.sameAs.toggle);(G===void 0||G.type!=="boolean")&&r.push({severity:"error",path:`${K}.toggle`,code:"ref.unknown-sameas-toggle",message:{de:G===void 0?`Feld '${O}': sameAs.toggle verweist auf das unbekannte Feld '${N.sameAs.toggle}'.`:`Feld '${O}': sameAs.toggle '${N.sameAs.toggle}' muss den Typ 'boolean' haben (ist '${G.type}').`,en:G===void 0?`Field '${O}' sameAs.toggle references unknown field '${N.sameAs.toggle}'.`:`Field '${O}' sameAs.toggle '${N.sameAs.toggle}' must be type 'boolean' (got '${G.type}').`}}),N.required===!0&&r.push({severity:"error",path:`fields[${O}].required`,code:"config.sameas-static-required",message:{de:`Feld '${O}' deklariert sameAs, ist aber statisch Pflicht \u2014 solange es gespiegelt ist, hat es keinen eigenen Wert, die Slice-Validierung beim Commit w\xFCrde immer scheitern. required: false + requiredIf: "${N.sameAs.toggle} != true" verwenden.`,en:`Field '${O}' declares sameAs but is statically required \u2014 while mirrored it holds no own value, so commit-time slice validation would always fail. Use required: false + requiredIf: "${N.sameAs.toggle} != true".`}})}{let O=new Map;e.effects.forEach(N=>O.set(N.id,N.kind)),e.effects.forEach((N,K)=>{if(N.kind!=="shareValue")return;[["from",N.from],["to",N.to]].forEach(([ae,ce])=>{let Ce=O.get(ce.slice(1));Ce!==void 0&&Ce!=="person"&&Ce!=="organization"&&r.push({severity:"error",path:`effects[${K}].${ae}`,code:"ref.sharevalue-endpoint",message:{de:`Effekt '${N.id}': shareValue ${ae} '${ce}' muss auf einen Person-/Organisations-Effekt verweisen (ist '${Ce}').`,en:`Effect '${N.id}' shareValue ${ae} '${ce}' must reference a person/organization effect (got '${Ce}').`}})});let C=N.from.slice(1);e.effects.some(ae=>ae.kind==="fieldMap"&&ae.target.slice(1)===C&&ae.mappings.some(ce=>ce.to===N.field)||ae.kind==="shareValue"&&ae.id!==N.id&&ae.to.slice(1)===C&&ae.field===N.field)||r.push({severity:"error",path:`effects[${K}].field`,code:"config.sharevalue-missing-source-map",message:{de:`Effekt '${N.id}' teilt das Feld '${N.field}' aus '${N.from}', aber kein fieldMap mit Ziel '${N.from}' bildet auf '${N.field}' ab (und kein shareValue verkn\xFCpft es) \u2014 der Quellwert k\xF6nnte beim Commit nie existieren.`,en:`Effect '${N.id}' shares field '${N.field}' from '${N.from}', but no fieldMap targeting '${N.from}' maps to '${N.field}' (and no shareValue links it in) \u2014 the source value could never exist at commit time.`}})})}e.effects.forEach((O,N)=>{O.kind==="person"&&O.bucket.includes(Ur)&&r.push({severity:"error",path:`effects[${N}].bucket`,code:"config.bucket-name-contains-hash",message:{de:`Effekt '${O.id}': bucket '${O.bucket}' darf '${Ur}' nicht enthalten (f\xFCr den Zeilen-Namensraum reserviert).`,en:`Effect '${O.id}' bucket '${O.bucket}' must not contain '${Ur}' (reserved for the per-row namespace).`}}),O.kind==="organization"&&O.orgKind.includes(Ur)&&r.push({severity:"error",path:`effects[${N}].orgKind`,code:"config.bucket-name-contains-hash",message:{de:`Effekt '${O.id}': orgKind '${O.orgKind}' darf '${Ur}' nicht enthalten (f\xFCr den Zeilen-Namensraum reserviert).`,en:`Effect '${O.id}' orgKind '${O.orgKind}' must not contain '${Ur}' (reserved for the per-row namespace).`}})});let fe=new Set;function Q(O,N){O.repeated?.forEach((K,C)=>{let G=K.effects??[];if(G.length>0){let ae=`${N}.repeated[${C}]`,ce=new Set(G.map(oe=>oe.id)),Ce=new Set(K.itemTemplate.map(oe=>oe.key)),Ae=(K.uniqueBy?.length??0)>0,hn=s(oe=>oe.startsWith("$item.")?Ce.has(oe.slice(6)):l.has(oe),"resolvesName"),Je=s(oe=>oe.startsWith("$item.")?Ce.has(oe.slice(6)):a.has(oe),"resolvesFrom"),An=s(oe=>{let Kn=oe.slice(1);return ce.has(Kn)||m.has(Kn)},"resolvesRef");G.forEach((oe,Kn)=>{let gn=`${ae}.effects[${Kn}]`;if(m.has(oe.id)||fe.has(oe.id)?r.push({severity:"error",path:gn,code:"duplicate.repeated-effect-id",message:{de:`Der Effekt '${oe.id}' der Wiederholung ist mehrfach deklariert.`,en:`Repeated effect id '${oe.id}' is declared more than once.`}}):fe.add(oe.id),oe.kind==="person"||oe.kind==="organization"){I(oe,gn),oe.kind==="person"&&oe.subject===!0&&r.push({severity:"error",path:`${gn}.subject`,code:"subject.in-repeated",message:{de:`Effekt '${oe.id}' der Wiederholung deklariert subject:true \u2014 eine Zeile gilt je Zeile, das Subjekt der Bewerbung je Bewerbung. Das Subjekt an einem Effekt der obersten Ebene deklarieren.`,en:`Repeated effect '${oe.id}' declares subject:true \u2014 a repeated row is per-row, the application subject is per-application. Declare the subject on a top-level effect.`}}),oe.kind==="person"&&oe.nationalityFrom!==void 0&&r.push({severity:"error",path:`${gn}.nationalityFrom`,code:"nationality.not-subject",message:{de:`Effekt '${oe.id}' der Wiederholung deklariert nationalityFrom \u2014 nur das Subjekt der Bewerbung (ein Effekt der obersten Ebene) tr\xE4gt es.`,en:`Repeated effect '${oe.id}' declares nationalityFrom \u2014 only the application subject (a top-level effect) carries it.`}}),oe.kind==="person"&&oe.contractParty!==void 0&&r.push({severity:"error",path:`${gn}.contractParty`,code:"contractParty.in-repeated",message:{de:`Effekt '${oe.id}' der Wiederholung deklariert contractParty \u2014 wer unterschreibt, wird einmal je Bewerbung deklariert, nicht je Zeile. An einem Effekt der obersten Ebene deklarieren.`,en:`Repeated effect '${oe.id}' declares contractParty \u2014 who signs is declared once per application, not once per row. Declare it on a top-level effect.`}}),Ae||r.push({severity:"error",path:ae,code:"config.repeated-effect-requires-uniqueBy",message:{de:`Wiederholung '${K.key}' hat einen Parteien erzeugenden Effekt '${oe.id}', aber kein 'uniqueBy' \u2014 Parteien je Zeile brauchen einen stabilen Identit\xE4tsschl\xFCssel.`,en:`Repeated def '${K.key}' has a party-creating effect '${oe.id}' but no 'uniqueBy' \u2014 per-row parties need a stable identity key.`}});let De=oe.kind==="person"?oe.bucket:oe.orgKind;De.includes(Ur)&&r.push({severity:"error",path:`${gn}.${oe.kind==="person"?"bucket":"orgKind"}`,code:"config.bucket-name-contains-hash",message:{de:`Effekt '${oe.id}' der Wiederholung: ${oe.kind==="person"?"bucket":"orgKind"} '${De}' darf '${Ur}' nicht enthalten.`,en:`Repeated effect '${oe.id}' ${oe.kind==="person"?"bucket":"orgKind"} '${De}' must not contain '${Ur}'.`}}),oe.kind==="person"&&r.push(...Y0(oe,G,gn,hn)),oe.kind==="organization"&&oe.nameFrom?.forEach((Ue,Ot)=>{hn(Ue)||r.push({severity:"error",path:`${gn}.nameFrom[${Ot}]`,code:"ref.unknown-name-field",message:{de:`Effekt '${oe.id}' der Wiederholung: nameFrom verweist auf das unbekannte Feld '${Ue}'.`,en:`Repeated effect '${oe.id}' nameFrom references unknown field '${Ue}'.`}})}),oe.identity?.strategy==="keyed"&&oe.identity.keyFrom.forEach((Ue,Ot)=>{Je(Ue)||r.push({severity:"error",path:`${gn}.identity.keyFrom[${Ot}]`,code:"ref.unknown-fieldmap-from",message:{de:`Effekt '${oe.id}' der Wiederholung: identity.keyFrom verweist auf das unbekannte Feld '${Ue}'.`,en:`Repeated effect '${oe.id}' identity.keyFrom references unknown field '${Ue}'.`}})})}else if(oe.kind==="relationship"){if([["from",oe.from],["to",oe.to]].forEach(([De,Ue])=>{An(Ue)||r.push({severity:"error",path:`${gn}.${De}`,code:"ref.unknown-repeated-effect",message:{de:`Beziehung '${oe.id}' der Wiederholung: ${De} verweist auf den unbekannten Effekt '${Ue}'.`,en:`Repeated relationship '${oe.id}' ${De} references unknown effect '${Ue}'.`}})}),oe.meta)for(let[De,Ue]of Object.entries(oe.meta))typeof Ue=="string"&&Ue.startsWith("$")&&!An(Ue)&&r.push({severity:"error",path:`${gn}.meta.${De}`,code:"ref.unknown-repeated-effect",message:{de:`Beziehung '${oe.id}' der Wiederholung: meta.${De} verweist auf den unbekannten Effekt '${Ue}'.`,en:`Repeated relationship '${oe.id}' meta.${De} references unknown effect '${Ue}'.`}})}else oe.kind==="fieldMap"?(An(oe.target)||r.push({severity:"error",path:`${gn}.target`,code:"ref.unknown-repeated-effect",message:{de:`fieldMap '${oe.id}' der Wiederholung: Ziel verweist auf den unbekannten Effekt '${oe.target}'.`,en:`Repeated fieldMap '${oe.id}' target references unknown effect '${oe.target}'.`}}),oe.mappings.forEach((De,Ue)=>{Je(De.from)||r.push({severity:"error",path:`${gn}.mappings[${Ue}].from`,code:"ref.unknown-fieldmap-from",message:{de:`fieldMap '${oe.id}' der Wiederholung: from '${De.from}' verweist auf ein unbekanntes Feld.`,en:`Repeated fieldMap '${oe.id}' from '${De.from}' references unknown field.`}})})):oe.kind==="shareValue"&&r.push({severity:"error",path:gn,code:"config.sharevalue-in-repeated",message:{de:`Effekt '${oe.id}' der Wiederholung: shareValue wird in Effekten von Wiederholungszeilen nicht unterst\xFCtzt.`,en:`Repeated effect '${oe.id}': shareValue is not supported inside repeated row effects.`}})})}}),O.subsections?.forEach((K,C)=>Q(K,`${N}.subsections[${C}]`))}s(Q,"visitRepeatedEffects"),e.sections.forEach((O,N)=>Q(O,`sections[${N}]`));let re=R0(t.effects);return re.hasCycle&&r.push({severity:"error",path:"effects",code:"graph.effect-cycle",message:{de:`Der Effektgraph enth\xE4lt einen Zyklus: ${re.cycle?.join(" \u2192 ")??"?"}`,en:`Effect graph contains a cycle: ${re.cycle?.join(" \u2192 ")??"?"}`}}),r.push(...y5(e)),r}s(H0,"validateForm");function y5(e){let n={...e,effects:e.effects.map(J0),sections:e.sections.map(Q0),testScenarios:e.testScenarios?.map(t=>({id:t.id,label:t.label,description:t.description}))};return op(n,"form").map(t=>({severity:"error",path:t.path,code:"i18n.missing-translation",message:Sw(t)}))}s(y5,"missingTranslationIssues");function J0(e){if(!("subject"in e))return e;let{subject:n,...t}=e;return t}s(J0,"withoutSubjectFlag");function Q0(e){return{...e,repeated:e.repeated?.map(n=>({...n,effects:n.effects?.map(J0)})),subsections:e.subsections?.map(Q0)}}s(Q0,"withoutRowSubjectFlags");function U0(e,n){let t=e.reviewRequired;return t===void 0||t===!0?[]:[{severity:"error",path:n,code:"review.shape",message:{de:`Feld '${e.key}' setzt reviewRequired auf ${JSON.stringify(t)} \u2014 erlaubt ist nur true; ein nicht pr\xFCfpflichtiges Feld l\xE4sst die Angabe weg.`,en:`Field '${e.key}' sets reviewRequired to ${JSON.stringify(t)} \u2014 only true is allowed; a field that needs no review omits it.`}}]}s(U0,"reviewRequiredShapeIssues");function G0(e,n){if(!e.export)return[];let t=[];return e.type==="docRef"&&t.push({severity:"error",path:n,code:"export.invalid-type",message:{de:`Feld '${e.key}' (docRef) kann nicht exportiert werden \u2014 ein Speicher-Handle ist kein bindbarer Dokumentwert.`,en:`Field '${e.key}' (docRef) cannot be exported \u2014 a storage handle is not a bindable document value.`}}),e.multiple===!0&&t.push({severity:"error",path:n,code:"export.multiple-enum",message:{de:`Feld '${e.key}' ist eine Mehrfachauswahl \u2014 N gew\xE4hlte Optionen sind kein einzelnes zusammengesetztes Blatt, deshalb nicht exportierbar.`,en:`Field '${e.key}' is a multi-select \u2014 N picked options are not one compound leaf, so it cannot be exported.`}}),t}s(G0,"exportGateIssues");function ka(e,n,t,r,i){e.has(n)?i.push({severity:"error",path:t,code:r,message:{de:`Mehrfach vergeben: ${z0(r,"de")} '${n}'`,en:`Duplicate ${z0(r,"en")}: '${n}'`}}):e.add(n)}s(ka,"reportIfDup");function z0(e,n){let t=s((r,i)=>n==="de"?r:i,"label");switch(e){case"duplicate.section-id":return t("Abschnitts-ID","section id");case"duplicate.field-key":return t("Feldschl\xFCssel","field key");case"duplicate.effect-id":return t("Effekt-ID","effect id");case"duplicate.outcome-id":return t("Ergebnis-ID","outcome id");case"ref.unknown-required-for-outcome":return t("requiredFor-Ergebnis","requiredFor outcome");default:return e}}s(z0,"labelForCode");function Bv(e,n,t,r,i,o){e.visibleIf&&(xr(e.visibleIf,`${n}.visibleIf`,t,r,o),ba(e.visibleIf,`${n}.visibleIf`,i,o)),e.requiredIf&&(xr(e.requiredIf,`${n}.requiredIf`,t,r,o),ba(e.requiredIf,`${n}.requiredIf`,i,o)),e.disabledIf&&(xr(e.disabledIf,`${n}.disabledIf`,t,r,o),ba(e.disabledIf,`${n}.disabledIf`,i,o)),e.defaultValue&&xr(e.defaultValue,`${n}.defaultValue`,t,r,o)}s(Bv,"checkFieldAsts");function Vv(e){return{hasDefault:e.defaultValue!=null,isBoolean:e.type==="boolean",isYesNo:e.type==="boolean"&&e.presentation==="yesNo",isConsent:e.type==="consent"}}s(Vv,"gatingMeta");function ba(e,n,t,r){function i(o){switch(o.kind){case"binary":{(o.op==="=="||o.op==="!=")&&(W0(o.left,o.right,o.op,n,t,r),W0(o.right,o.left,o.op,n,t,r)),i(o.left),i(o.right);return}case"unary":i(o.operand);return;case"if":i(o.cond),i(o.then),i(o.else);return;case"call":o.args.forEach(i);return;case"arr":o.items.forEach(i);return;default:return}}s(i,"walk"),i(e)}s(ba,"checkGatingExpr");function W0(e,n,t,r,i,o){if(e.kind!=="ident")return;let a=i.get(e.path);if(a){if(a.isConsent&&n.kind==="bool"&&n.value===!1){o.push({severity:"error",path:r,code:"expr.consent-compare-false",message:{de:`Gating-Ausdruck vergleicht die Zustimmung '${e.path}' mit false \u2014 eine Zustimmung ist true oder leer, nie false. '${e.path} != true' verwenden.`,en:`Gating expression compares the consent '${e.path}' to false \u2014 a consent is true or empty, never false. Use '${e.path} != true'.`}});return}a.isBoolean&&(a.hasDefault||n.kind!=="null"&&n.kind==="bool"&&(a.isYesNo&&t==="=="||o.push({severity:"error",path:r,code:"expr.gating-compare-undefaulted-field",message:{de:`Gating-Ausdruck vergleicht das Boolean-Feld '${e.path}' ohne Standardwert per '${t}' mit einem Bool-Literal. In dreiwertiger Logik ist 'undefined ${t} ${n.value}' ${t==="=="?"false":"true"} \u2014 das Gate greift stillschweigend bei ungesetzten Werten. Dem Feld '${e.path}' einen 'defaultValue' geben (oder den Ausdruck umschreiben \u2014 z. B. '${e.path} != null' als ausdr\xFCckliche Gesetzt-Pr\xFCfung).`,en:`Gating expression compares undefaulted boolean field '${e.path}' to a bool literal via '${t}'. In three-valued logic, 'undefined ${t} ${n.value}' is ${t==="=="?"false":"true"} \u2014 the gate fires silently for unset values. Add a 'defaultValue' to field '${e.path}' (or rewrite the expression \u2014 e.g. '${e.path} != null' for an explicit set-check).`}})))}}s(W0,"inspectEqualityOperand");function xr(e,n,t,r,i){i.push(...hN(e,t.declaredContext,n)),i.push(...np(e,t.stageKeys,n));for(let o of xn(e))t.known.has(o)||kw(o)||r&&o.startsWith("$item.")||i.push({severity:"error",path:n,code:"ref.unknown-ident",message:{de:o.startsWith("$")?`Bezeichner '${o}' ist kein Geltungsbereich, den ein Formular liest \u2014 Umgebungsvariablen sind '$env.<key>.<field>', Wiederholungszeilen '$item.*'.`:`Bezeichner '${o}' ist weder als Feld, berechneter Schl\xFCssel noch als $item-Slot deklariert.`,en:o.startsWith("$")?`Identifier '${o}' is no scope a form reads \u2014 environment variables are '$env.<key>.<field>', repeated rows '$item.*'.`:`Identifier '${o}' is not declared as a field, computed key, or $item slot.`}})}s(xr,"checkAst");function Y0(e,n,t,r){let i=[];e.nameFrom!==void 0&&i.push({severity:"error",path:`${t}.nameFrom`,code:"person.name-from-removed",message:{de:`Effekt '${e.id}': eine Person hat kein nameFrom mehr \u2014 ihr Name ist die Feldzuordnung (fieldMap) auf ${vr.firstName} / ${vr.lastName}. nameFrom entfernen.`,en:`Effect '${e.id}': a person has no nameFrom any more \u2014 its name is the fieldMap onto ${vr.firstName} / ${vr.lastName}. Remove nameFrom.`}});let o=L0(e.id,n);q0(o)||i.push({severity:"error",path:t,code:"person.without-name-mapping",message:{de:`Effekt '${e.id}': keine Feldzuordnung (fieldMap) auf ${vr.firstName} oder ${vr.lastName} \u2014 die Person bek\xE4me keinen Namen.`,en:`Effect '${e.id}': no fieldMap onto ${vr.firstName} or ${vr.lastName} \u2014 the person would get no name.`}});for(let a of M0(o))r(a)||i.push({severity:"error",path:t,code:"ref.unknown-name-field",message:{de:`Effekt '${e.id}': der Name wird aus '${a}' gelesen, das kein eingegebenes Feld ist.`,en:`Effect '${e.id}': its name is read from '${a}', which is not an entered field.`}});return i}s(Y0,"personNameIssues");function w5(e,n){let t=[],r=e.required===!0||e.requiredIf!==void 0;return e.type==="consent"&&(e.defaultValue!=null&&t.push({severity:"error",path:n,code:"config.consent-default",message:{de:`Feld '${e.key}' ist eine Zustimmung mit einem defaultValue \u2014 zustimmen muss die Familie selbst. Den defaultValue entfernen.`,en:`Field '${e.key}' is a consent with a defaultValue \u2014 the family must give it themselves. Remove the defaultValue.`}}),e.sameAs!==void 0&&t.push({severity:"error",path:n,code:"config.consent-computed",message:{de:`Feld '${e.key}' ist eine Zustimmung, die ein anderes Feld spiegelt (sameAs) \u2014 zustimmen muss die Familie selbst. sameAs entfernen.`,en:`Field '${e.key}' is a consent mirroring another field (sameAs) \u2014 the family must give it themselves. Remove sameAs.`}}),r||t.push({severity:"error",path:n,code:"config.consent-not-required",message:{de:`Feld '${e.key}' ist eine Zustimmung, die nie verlangt wird \u2014 required: true oder requiredIf setzen, sonst Typ 'boolean' verwenden.`,en:`Field '${e.key}' is a consent nobody is asked to give \u2014 set required: true or requiredIf, or use type 'boolean'.`}})),e.type==="boolean"&&r&&e.defaultValue?.trim()==="false"&&t.push({severity:"warning",path:n,code:"config.boolean-required-default-false",message:{de:`Feld '${e.key}' ist ein Ja/Nein-Pflichtfeld, vorbelegt mit Nein \u2014 es gilt von Anfang an als ausgef\xFCllt. Ist es eine Zustimmung, Typ 'consent' verwenden.`,en:`Field '${e.key}' is a required yes/no preset to No \u2014 it counts as answered from the start. If it is a consent, use type 'consent'.`}}),t}s(w5,"consentConfigIssues");var k5="blocked";function Z0(e,n){let t={values:n};for(let r of e.outcomes){let i;try{i=un(r.when,t)}catch(o){F(`resolveActiveOutcome: outcome "${r.id}" when-expression threw: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(b5(i))return r.id===k5?null:r.id}return null}s(Z0,"resolveActiveOutcome");function b5(e){return!(e==null||e===!1||e===0||e===""||Array.isArray(e)&&e.length===0)}s(b5,"truthy");function X0(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}s(X0,"isScalar");function v5(e,n,t){for(let[r,i]of Object.entries(e))if(i!==void 0){if(X0(i)){n[r]=i;continue}if(Array.isArray(i)){n[r]=i;continue}for(let[o,a]of Object.entries(i))X0(a)&&(n[`${r}.${o}`]=a)}x5(e,n,t)}s(v5,"mergeRecord");function x5(e,n,t){let r=new Set(t);for(let i of Object.keys(e)){let o=i.indexOf("[");if(o<=0)continue;let a=i.slice(0,o);Wi(a).test(i)&&r.add(a)}for(let i of r){let o=qv(e,i),a=0;for(let l=0;l<o;l++)O0(e,i,l)&&a++;n[`${i}.count`]=a}}s(x5,"mergeRepeatedCounts");function eM(e,n,t){let r={...t};return v5(e,r,n),r}s(eM,"flattenValues");function Uv(e,n,t){return{code:e,fieldKey:n,text:t}}s(Uv,"submitIssue");function nM(e){return!(e==null||e===!1||e===0||e===""||Array.isArray(e)&&e.length===0)}s(nM,"truthyEval");function tM(e){if(e==null)return!0;if(typeof e=="string")return e.trim()==="";if(Array.isArray(e))return e.length===0;if(typeof e=="object"){let n=e;if("storageId"in n)return!(typeof n.storageId=="string"&&n.storageId.trim()!=="");let t=n;return!t.street?.trim()||!t.hausnr?.trim()||!t.plz?.trim()||!t.ort?.trim()||!t.land?.trim()}return!1}s(tM,"isEmptyValue");function S5(e,n,t){let r=!!e.required;if(!r&&e.requiredIf)try{r=nM(un(e.requiredIf,{values:n}))}catch{r=!1}return r?e.requiredFor?t===null?!1:e.requiredFor.includes(t):!0:!1}s(S5,"fieldIsLiveRequired");function A5(e,n,t){return rM(e,n,t).evalCtx}s(A5,"buildSubmitEvalContext");function rM(e,n,t){let r=E5(e),i=Object.keys(n).filter(l=>r(l)!==null),o=new Set(i),a=new Set;for(;;){let l={};for(let[y,k]of Object.entries(n))(r(y)===null||o.has(y))&&(l[y]=k);let d=iM(e,l,t),c=new Set,u=new Set;sM(e,d,y=>c.add(y.key),y=>u.add(y.key));let p=new Set(i.filter(y=>{let k=r(y);return k.kind==="field"?c.has(y):u.has(k.repeatedKey)}));if(p.size===o.size&&[...p].every(y=>o.has(y))){let y={};for(let k of i)o.has(k)||(y[k]=n[k]);return{visible:l,hidden:y,evalCtx:d}}let m=[...p].sort().join("\0");if(a.has(m)){let y=i.filter(k=>p.has(k)!==o.has(k));F(`[smartForm] visibility of ${y.join(", ")} does not settle \u2014 each depends on whether the other's value counts. The form's visibleIf conditions are contradictory.`)}a.add(m),o=p}}s(rM,"splitWithContext");function E5(e){let n=new Map,t=[];for(let r of Dm(e.sections)){for(let i of r.fields)n.set(i.key,i);for(let i of r.groups??[])for(let o of i.fields)n.set(o.key,o);for(let i of r.repeated??[])t.push({key:i.key,pattern:Wi(i.key),items:new Map(i.itemTemplate.map(o=>[o.key,o]))})}return r=>{let i=n.get(r);if(i!==void 0)return{kind:"field",field:i};for(let o of t){let a=o.pattern.exec(r);if(a!==null)return{kind:"row",repeatedKey:o.key,field:o.items.get(a[2])}}return null}}s(E5,"fieldOwnership");function iM(e,n,t){let r=[];for(let o of Dm(e.sections))for(let a of o.repeated??[])r.push(a.key);let i=eM(n,r,t);for(let o of Dm(e.sections))for(let a of o.computed??[])try{i[a.key]=un(a.expression,{values:i})}catch{}return i}s(iM,"rawEvalContext");function oM(e,n,t){let{values:r,defaulted:i}=T5(e,n,t),o=rM(e,r,t),a={};for(let[l,d]of Object.entries(o.hidden))i.has(l)||(a[l]=d);return{...o,hidden:a}}s(oM,"splitDraftValues");function T5(e,n,t,r){let i={...n},o=new Set,a=null;for(let l of Dm(e.sections))for(let d of[...l.fields,...(l.groups??[]).flatMap(c=>c.fields)]){if(!d.defaultValue||n[d.key]!=null||r?.(d.key))continue;a??=iM(e,n,t);let c;try{c=un(d.defaultValue,{values:a})}catch(u){F(`[smartForm] defaultValue of '${d.key}' does not evaluate: ${u instanceof Error?u.message:String(u)}`)}c!=null&&(i[d.key]=c,o.add(d.key))}return{values:i,defaulted:o}}s(T5,"applyFieldDefaults");function Dm(e){let n=[],t=s(r=>{n.push(r);for(let i of r.subsections??[])t(i)},"walk");for(let r of e)t(r);return n}s(Dm,"walkSectionsDeep");function $5(e,n,t,r=!1){if(tM(n))return null;let i=t.fields[e.type];i||F(`[fieldFormatIssue] no field provider registered for type "${e.type}" (field "${e.key}"). Register it in the domain form registry.`);let o=i.validate(e,n,{state:{values:{},computed:{}},testMode:r});return o.length>0?o[0].message:null}s($5,"fieldFormatIssue");function R5(e,n){return tM(n)||e.type==="consent"&&n!==!0}s(R5,"isUnanswered");function Cm(e,n){if(!e)return!0;try{return nM(un(e,{values:n}))}catch{return!1}}s(Cm,"isVisibleUnder");function sM(e,n,t,r){let i=s(o=>{if(Cm(o.visibleIf,n)){for(let a of o.fields)Cm(a.visibleIf,n)&&t(a);for(let a of o.groups??[])if(Cm(a.visibleIf,n))for(let l of a.fields)Cm(l.visibleIf,n)&&t(l);if(r!==void 0)for(let a of o.repeated??[])r(a);for(let a of o.subsections??[])i(a)}},"walk");for(let o of e.sections)i(o)}s(sM,"forEachVisibleField");function aM(e,n,t,r={}){let i=A5(e,n,t),o=[],a=Z0(e,i);a===null&&r.requireOutcome!==!1&&o.push(Uv("no-outcome",null,{de:"Die Angaben ergeben keinen g\xFCltigen Abschluss \u2014 bitte pr\xFCfen Sie das Formular.",en:"The answers do not lead to a valid outcome \u2014 please check the form."}));let l=new Set(r.exemptFromRequired??[]);return sM(e,i,d=>{let c=n[d.key];if(R5(d,c)){!l.has(d.type)&&S5(d,i,a)&&o.push(Uv("required",d.key,dl([d.label],([p],m)=>m==="de"?`${p} ist ein Pflichtfeld.`:`${p} is a required field.`)));return}if(!r.registry)return;let u=$5(d,c,r.registry,r.testMode===!0);u!==null&&o.push(Uv("format",d.key,u))}),{issues:o,activeOutcome:a,evalCtx:i,submittable:o.length===0}}s(aM,"checkSubmittable");function lM(e){let n=e.testScenarios??[];if(n.length===0)return[];let{compiled:t}=Zs(e),r=[];for(let i of n){let o=i.prefill??{};if(!cN(e,i.env))continue;let a=fN(e,i.env),{visible:l}=oM(t,o,a),d=aM(t,l,a,{exemptFromRequired:["docRef"]});for(let c of d.issues){if(c.code==="no-outcome"){r.push({severity:"error",path:`scenario:${i.id}`,code:"scenario.no-outcome",message:{de:`Szenario "${i.label.de}" erreicht kein g\xFCltiges Outcome \u2013 der Testfall ist nicht absendbar.`,en:`Scenario "${i.label.en}" reaches no valid outcome \u2013 the test case cannot be submitted.`}});continue}if(c.code==="required"){r.push({severity:"error",path:`scenario:${i.id}/${c.fieldKey}`,code:"scenario.required-field-unfilled",message:{de:`Szenario "${i.label.de}" l\xE4sst das Pflichtfeld ${c.fieldKey} unbef\xFCllt \u2013 kein g\xFCltiges Outcome.`,en:`Scenario "${i.label.en}" leaves the required field ${c.fieldKey} empty \u2013 no valid outcome.`}});continue}r.push({severity:"error",path:`scenario:${i.id}/${c.fieldKey}`,code:"scenario.invalid-value",message:dl([i.label,c.text],([u,p],m)=>m==="de"?`Szenario "${u}": ${p}`:`Scenario "${u}": ${p}`)})}}return r}s(lM,"validateScenarios");function Fm(e){return e.filter(n=>(n.severity??"error")==="error")}s(Fm,"blockingIssues");function Lm(e,n={}){return[...H0(e,n),...lM(e)]}s(Lm,"runFormValidators");function Mm(e){return Fm(e)}s(Mm,"blockingFormErrors");function dM(e,n,t){return A_(e,n,t)}s(dM,"runWorkflowValidators");function cM(e){return Fm(e)}s(cM,"blockingWorkflowErrors");var I5=["actionTeams","artifacts","assign","inputs","library","next","notifications","optionalActions","outcomes","outputLabels","sublabel","tasks"],uM={join:{required:[],optional:[]},end:{required:[],optional:[]},eventTrigger:{required:[],optional:[]},form:{required:[],optional:["adoptForm","formExports"]},roleAssign:{required:[],optional:[]},setFlag:{required:[],optional:[]},if:{required:["condition"],optional:[]},countersign:{required:["contract"],optional:["signing","titles"]},engagePush:{required:["form"],optional:["contract","engage","payment"]},decision:{required:[],optional:["commentRequired","decisionAsTask","formView","reads","requiresOneOf"]},review:{required:[],optional:["commentRequired","decisionAsTask","form"]},waitlist:{required:[],optional:[]},completenessCheck:{required:["deadline","requires"],optional:[]},collectPayment:{required:[],optional:[]},governedDocument:{required:["approval","production","responseStrategy"],optional:["confirmBeforeIssue","confirmContractTerms","contractTermsQuestionText","form","generatorStamp","reads","responseLabels","templateStamp","titles"]}},pt={id:w.string(),label:ua,actionTeams:w.optional(w.any()),artifacts:w.optional(w.any()),assign:w.optional(w.any()),inputs:w.optional(w.any()),library:w.optional(w.any()),next:w.optional(w.any()),notifications:w.optional(w.any()),optionalActions:w.optional(w.any()),outcomes:w.optional(w.any()),outputLabels:w.optional(w.any()),sublabel:w.optional(w.any()),tasks:w.optional(w.any())},O5=w.object({...pt,type:w.literal("join")}),P5=w.object({...pt,type:w.literal("end")}),N5=w.object({...pt,type:w.literal("eventTrigger")}),_5=w.object({...pt,type:w.literal("form"),adoptForm:w.optional(w.any()),formExports:w.optional(w.any())}),C5=w.object({...pt,type:w.literal("roleAssign")}),D5=w.object({...pt,type:w.literal("setFlag")}),F5=w.object({...pt,type:w.literal("if"),condition:w.optional(w.any())}),L5=w.object({...pt,type:w.literal("countersign"),contract:w.optional(w.any()),signing:w.optional(w.any()),titles:w.optional(w.any())}),M5=w.object({...pt,type:w.literal("engagePush"),contract:w.optional(w.any()),engage:w.optional(w.any()),form:w.optional(w.any()),payment:w.optional(w.any())}),q5=w.object({...pt,type:w.literal("decision"),commentRequired:w.optional(w.any()),decisionAsTask:w.optional(w.any()),reads:w.optional(w.any()),requiresOneOf:w.optional(w.any()),formView:w.optional(w.any())}),K5=w.object({...pt,type:w.literal("review"),commentRequired:w.optional(w.any()),decisionAsTask:w.optional(w.any()),form:w.optional(w.any())}),j5=w.object({...pt,type:w.literal("waitlist")}),B5=w.object({...pt,type:w.literal("completenessCheck"),deadline:w.optional(w.any()),requires:w.optional(w.any())}),V5=w.object({...pt,type:w.literal("collectPayment")}),U5=w.object({...pt,type:w.literal("governedDocument"),approval:w.optional(w.any()),confirmBeforeIssue:w.optional(w.any()),confirmContractTerms:w.optional(w.any()),contractTermsQuestionText:w.optional(w.any()),form:w.optional(w.any()),generatorStamp:w.optional(w.any()),production:w.optional(w.any()),reads:w.optional(w.any()),responseLabels:w.optional(w.any()),responseStrategy:w.optional(w.any()),templateStamp:w.optional(w.any()),titles:w.optional(w.any())}),BDe=w.union(O5,P5,N5,_5,C5,D5,F5,L5,M5,q5,K5,j5,B5,V5,U5);function fM(e){let n=[];return e.forEach((t,r)=>{if(t===null||typeof t!="object"||Array.isArray(t)){n.push(`graph.nodes[${r}]: a node must be an object`);return}let i=t,o=`graph.nodes[${r}]${typeof i.id=="string"?` (${i.id})`:""}`;(typeof i.id!="string"||i.id==="")&&n.push(`${o}: \`id\` must be a non-empty string`);let a=i.type;if(typeof a!="string"||!(a in uM)){n.push(`${o}: unknown node type ${JSON.stringify(a)}`);return}let l=uM[a],d=new Set(["id","type","label",...I5,...l.required,...l.optional]);for(let c of Object.keys(i))d.has(c)||n.push(`${o}: \`${c}\` is not a field of a ${a} node. Delete the line.`)}),n}s(fM,"workflowNodeEnvelopeIssues");function pM(e,n){return e.enumOptionLabels?.[n]??{de:n,en:n}}s(pM,"inlineEnumOptionLabel");var hM={string:"string",boolean:"boolean",consent:"boolean",date:"date",enum:"enum",email:"email",tel:"tel",address:"address"};function gM(e){return hM[e]!==void 0}s(gM,"isExportableFieldType");function G5(e){return e.exportType===void 0&&F(`formExports: computed '${e.key}' is exported without an exportType \u2014 the publish validator should have refused this form.`),{key:e.key,type:e.exportType,label:e.label??{de:e.key,en:e.key}}}s(G5,"leafForComputed");function mM(e){let n=hM[e.type];return n===void 0&&F(`formExports: field '${e.key}' has type '${e.type}', which is not exportable \u2014 the publish validator should have refused this form.`),{key:e.key,type:n,label:e.label,...e.enumOptions!==void 0?{enumOptions:e.enumOptions.map(t=>({value:t,label:pM(e,t)}))}:{}}}s(mM,"leafFor");function Gv(e){let n=[],t=s(r=>{for(let i of r.fields)i.export===!0&&n.push(mM(i));for(let i of r.groups??[])for(let o of i.fields)o.export===!0&&n.push(mM(o));for(let i of r.computed??[])i.export===!0&&n.push(G5(i));for(let i of r.subsections??[])t(i)},"visit");for(let r of e.sections)t(r);return n}s(Gv,"exportedFormLeaves");var yM=s(e=>e,"asEffectId"),Yi=s(e=>e,"asOutcomeId"),va=s(e=>e,"asSectionId"),ot=s(e=>e,"asFieldKey");var Sr=["string","boolean","consent","date","enum","email","tel","address","docRef"],Nd=["person","organization","relationship","fieldMap"],Hi=["auto-on-any-write","auto-on-required-complete","workflow-explicit"],xa=["fresh","keyed","manual"];function Uo(e,n,t,r){if(e===void 0||e===""){if(n!==void 0&&n!=="")throw new Error(`${t}: ${r}-en needs ${r} too`);return}return ln(e,n,t,r)}s(Uo,"optionalLocalizedText");function Jn(e,n){if(!(e===void 0||e===""))try{In(e)}catch(t){throw new Error(`offer form: ${n} is not a valid expression: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}s(Jn,"assertExpression");function _d(e){return Object.keys(e.smartforms??{})}s(_d,"carriedFormSlugs");function zv(e){let t=e.workflow?.graph?.nodes??[],r=[];for(let i of t){if(i.type!=="form")continue;let o=i.inputs?.smartForm;o?.kind==="literal"&&typeof o.value=="string"&&o.value&&r.push(o.value)}return r}s(zv,"boundFormSlugs");function qm(e,n){let t=_d(e);if(n){if(!t.includes(n))throw new Error(`offer form: no smartform "${n}" in this bundle (have: ${t.join(", ")||"none"})`);return n}if(t.length===0)throw new Error("offer form: bundle carries no smartforms \u2014 run `offer form add` first");if(t.length>1)throw new Error(`offer form: bundle carries ${t.length} smartforms \u2014 pass --form <key> (one of: ${t.join(", ")})`);return t[0]}s(qm,"resolveFormSlug");function Km(e,n){let t=e.smartforms?.[n];if(!t)throw new Error(`offer form: smartform "${n}" not found in bundle`);return t}s(Km,"getForm");function Kt(e){let n=[],t=s(r=>{n.push(r),r.subsections?.forEach(i=>t(i))},"visit");return e.sections.forEach(t),n}s(Kt,"walkSections");function rr(e,n){return Kt(e).find(t=>t.id===n)}s(rr,"findSection");function Go(e,n){for(let t of Kt(e)){let r=t.fields.findIndex(i=>i.key===n);if(r>=0)return{section:t,field:t.fields[r],index:r}}}s(Go,"findField");function zo(e){let n=new Set;for(let t of Kt(e))t.fields.forEach(r=>n.add(r.key)),t.groups?.forEach(r=>r.fields.forEach(i=>n.add(i.key))),t.repeated?.forEach(r=>r.itemTemplate.forEach(i=>n.add(i.key))),t.computed?.forEach(r=>n.add(r.key));return n}s(zo,"allFieldKeys");function z5(e){let n=ln(e.label,e.labelEn,"offer form add"),t={id:va("section.allgemein"),label:{de:"Allgemein",en:"General"},fields:[]},r={id:Yi("standard"),label:{de:"Standard",en:"Standard"},when:"true",output:{includeForm:!0}};return{label:n,sections:[t],effects:[],outcomes:[r]}}s(z5,"buildSkeletonSmartForm");function jm(e,n){let{key:t,label:r}=n;if(_d(e).includes(t))throw new Error(`offer form add: smartform "${t}" already exists in this bundle`);let i=z5({key:t,label:r,...n.labelEn?{labelEn:n.labelEn}:{}});e.smartforms={...e.smartforms??{},[t]:i},e.index.smartforms={...e.index.smartforms??{},[t]:{}}}s(jm,"addForm");function wM(e,n){if(!_d(e).includes(n))throw new Error(`offer form rm: smartform "${n}" not found in bundle`);if(zv(e).includes(n))throw new Error(`offer form rm: smartform "${n}" is still bound by a form node \u2014 remove the form node first (offer workflow node rm), then the form`);return delete e.smartforms[n],e.index.smartforms&&delete e.index.smartforms[n],n}s(wM,"removeForm");function kM(e,n){let t=Km(e,n.slug);if(n.label===void 0&&n.labelEn===void 0)throw new Error("offer form set: nothing to change \u2014 pass --label/--label-en");if(n.label==="")throw new Error("offer form set: --label cannot be empty");bn(t,"label",{de:n.label,en:n.labelEn},"offer form set")}s(kM,"setForm");function bM(e,n){let t=e.workflow?.graph?.nodes;if(!Array.isArray(t))throw new Error(`${n}: the bundle carries no workflow graph (workflow.json)`);return t}s(bM,"nodesOf");function vM(e,n,t){let r=bM(e,t),i=r.find(o=>o.id===n);if(i===void 0)throw new Error(`${t}: no node "${n}" (nodes: ${r.map(o=>o.id).join(", ")})`);return i}s(vM,"nodeOf");function xM(e){return e.flatMap(n=>{if(n.type!=="form"||vt(n))return[];let t=n.inputs?.smartForm;return t?.kind==="literal"&&typeof t.value=="string"&&t.value!==""?[{node:n,slug:t.value}]:[]})}s(xM,"creatingFormNodes");function SM(e){return Mm(Lm(e)).map(n=>`[${n.code??"form"}] ${n.path?`${n.path}: `:""}${n.message.de}`)}s(SM,"formErrors");function Bm(e){let n="offer workflow restamp-exports",t=bM(e,n),r=[];for(let{node:i,slug:o}of xM(t)){let a=e.smartforms?.[o];if(a===void 0)throw new Error(`${n}: form node "${i.id}" binds smartForm "${o}", but the bundle carries no smartforms/${o}.json`);let l=a,d=SM(l);if(d.length>0)throw new Error(`${n}: smartform "${o}" is refused by the publish gate \u2014 fix it first:
|
|
11256
11259
|
${d.join(`
|
|
11257
|
-
`)}`);let c=Gv(l),u=Array.isArray(i.formExports)?i.formExports.map(m=>m.key):null,p=i.formExports===void 0||Pe(i.formExports)!==Pe(c);i.formExports=c,r.push({node:i.id,form:o,before:u,after:c.map(m=>m.key),changed:p})}for(let i of t)if(i.type==="form"&&vt(i)&&"formExports"in i){let o=i.formExports?.map(a=>a.key)??null;delete i.formExports,r.push({node:i.id,form:"(adoptForm)",before:o,after:[],changed:!0})}return r}s(Bm,"restampFormExports");function AM(e){let n=e.workflow?.graph?.nodes??[];return xM(n).flatMap(({node:t,slug:r})=>{if(t.formExports===void 0)return[];let i=e.smartforms?.[r];if(i===void 0)return[];let o=i;return SM(o).length>0?[]:Pe(t.formExports)===Pe(Gv(o))?[]:[{node:t.id,form:r}]})}s(AM,"staleFormExports");var Wv=["string","number","boolean","date"];function EM(e,n){let t="offer form field export";for(let r of Kt(e)){let i=[...r.fields,...(r.groups??[]).flatMap(a=>a.fields)].find(a=>a.key===n.key);if(i!==void 0){if(n.type!==void 0)throw new Error(`${t}: --type is for a computed field; "${n.key}" is an entered ${i.type} field and exports as its own type`);if(n.on&&!gM(i.type))throw new Error(`${t}: "${n.key}" is a ${i.type} field \u2014 that type has no exported value (export.invalid-type)`);if(n.on&&i.multiple===!0)throw new Error(`${t}: "${n.key}" is a multi-select \u2014 N picked options are no single leaf (export.multiple-enum)`);let a=i.export===!0,l=i;return n.on?l.export=!0:delete l.export,{kind:"field",before:a,after:n.on}}let o=(r.computed??[]).find(a=>a.key===n.key);if(o!==void 0){let a=o.export===!0,l=o;if(!n.on){if(n.type!==void 0)throw new Error(`${t}: --type goes with an export, not with --off`);return delete l.export,delete l.exportType,{kind:"computed",before:a,after:!1}}let d=n.type??o.exportType;if(d===void 0)throw new Error(`${t}: "${n.key}" is a computed field \u2014 name its type with --type (${Wv.join("|")}); an expression has none to infer`);if(!Wv.includes(d))throw new Error(`${t}: --type "${d}" is no computed export type (${Wv.join("|")})`);return l.export=!0,l.exportType=d,{kind:"computed",before:a,after:!0}}if((r.repeated??[]).some(a=>a.itemTemplate.some(l=>l.key===n.key)))throw new Error(`${t}: "${n.key}" sits in a repeated block \u2014 a row value is no per-application leaf (export.in-repeated)`)}throw new Error(`${t}: the form has no field "${n.key}"`)}s(EM,"setFieldExport");function TM(e,n,t){let r="offer workflow node set-generator",i=vM(e,n,r);if(Im(i)!=="resolver")throw new Error(`${r}: "${n}" generates no contract from a generator (${i.type==="governedDocument"?`production ${String(i.production)}`:String(i.type)}) \u2014 a pin belongs on a governedDocument with production resolver`);let a=t.key.trim();if(a==="")throw new Error(`${r}: the ${t.kind} key is empty`);let l=ni(i),d=l!==null&&l.key===a&&l.kind===t.kind&&l.revision===void 0,c=!d&&"generatorStamp"in i;c&&delete i.generatorStamp,i.inputs={...i.inputs??{},[Vn]:{kind:"literal",value:{kind:t.kind,key:a}}};let u=d?[]:Object.keys(i.inputs).filter(p=>p!==Vn&&p!==_t);return{before:l,after:{key:a,kind:t.kind},droppedStamp:c,keptParameterCells:u}}s(TM,"setGeneratorPin");function $M(e,n,t){let r="offer workflow node set-cockpit-fields",i=vM(e,n,r),o=Im(i);if(o!=="resolver"&&o!=="template")throw new Error(`${r}: "${n}" fills no document from a generator or a Word template (${i.type==="governedDocument"?`production ${String(i.production)}`:String(i.type)})`);if(!(o==="resolver"?ni(i)!==null:pr(i)!==null))throw new Error(o==="resolver"?`${r}: "${n}" names no generator yet \u2014 name one first (offer workflow node set-generator)`:`${r}: "${n}" names no Word template yet \u2014 name one first (inputs.documentTemplate)`);let l=new Set;for(let p of t){if(l.has(p))throw new Error(`${r}: --fields names "${p}" twice`);l.add(p)}let d={...i.inputs??{}},c=Object.keys(d).filter(p=>d[p]?.kind==="cockpit"),u=t.flatMap(p=>{let m=d[p];return m===void 0||m.kind==="cockpit"||m.kind==="unset"?[]:[{field:p,cell:m}]});for(let p of c)l.has(p)||delete d[p];for(let p of t)d[p]={kind:"cockpit"};return i.inputs=d,{pin:o,before:c,after:[...t],replaced:u}}s($M,"setCockpitFields");var W5=new Set(["graph","progressLayout","progressWiring"]);function RM(e){let{label:n,...t}=e;return t}s(RM,"definitionOf");function Y5(e){let n=[];for(let o of Object.keys(e))W5.has(o)||n.push(`workflow.json: unknown key \`${o}\` \u2014 the file carries only graph, progressLayout, progressWiring. Delete the line.`);let t=e.graph;if(t===null||typeof t!="object"||Array.isArray(t))return n.push("workflow.json: `graph` must be an object."),n;for(let o of Object.keys(t)){if(uI.has(o))continue;let a=o==="id"||o==="label"?" (the title is the offer's, bundle.yaml `label`)":o==="dataFlow"?" (publish derives it)":"";n.push(`workflow.json: \`graph.${o}\` is no longer part of the workflow graph${a}. Delete the line.`)}let r=t;Array.isArray(r.nodes)?n.push(...fM(r.nodes).map(o=>`workflow.json: ${o}`)):n.push("workflow.json: `graph.nodes` must be a list."),r.assignmentRules===void 0&&n.push("workflow.json: `graph.assignmentRules` is required (who becomes responsible).");let i=e.progressWiring;return i!=null&&typeof i=="object"&&"layoutId"in i&&n.push("workflow.json: `progressWiring.layoutId` is no longer part of the wiring (the layout is the workflow's own). Delete the line."),n}s(Y5,"workflowShapeIssues");function IM(e){let n=e.nodes??[],t=new Map;for(let r of n){let i=iO(r);i!==void 0&&t.set(r.id,i)}return t}s(IM,"formNodeSlugById");function H5(e,n){let t=e.smartforms??{},r=new Map;for(let[i,o]of IM(n)){let a=t[o];if(a===void 0)return;r.set(i,RM(a))}return xN(r)}s(H5,"readinessContext");function J5(e){return[...IM(e).values()]}s(J5,"formNodeSlugs");function Vm(e){let n=e.code?`[${e.code}] `:"",t=e.path?`${e.path}: `:"",r=e.reason??e.message;return`${n}${t}${r===void 0?JSON.stringify(e):r.de}`}s(Vm,"describe");function Rt(e){let n=[];for(let l of df(e.manifest))n.push({severity:"error",area:"manifest",message:l});let t=Rn(e.index.label);(t==="not-localized"||t.length>0)&&n.push({severity:"error",area:"manifest",message:`[i18n/missingTranslation] bundle.yaml label fehlt in: ${t==="not-localized"?"de, en":t.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`});let{manifest:r,workflow:i}=e.index.slugs;i!==void 0&&i!==r&&n.push({severity:"error",area:"workflow",message:`slugs.workflow '${i}' must equal slugs.manifest '${r}' \u2014 the workflow belongs to the offer family, and export writes the family key`});for(let l of dm(e.index.program?.stages??[]))n.push({severity:"error",area:"program",message:l.message.de});for(let l of fm(e.index.program?.runs??[]))n.push({severity:"error",area:"program",message:l.message.de});for(let l of pm(e.index.program?.runs??[],e.index.program?.stages?.map(d=>d.key)))n.push({severity:"error",area:"program",message:l});if(e.workflow!==void 0){for(let E of Y5(e.workflow))n.push({severity:"error",area:"workflow",message:E});let l=e.workflow.graph,d=e.workflow.progressLayout,c=e.workflow.progressWiring;if(d!==void 0)for(let E of cI(d))n.push({severity:"error",area:"workflow",message:E});let u=[];for(let{node:E,key:A,kind:I}of Om(e))E.generatorStamp?.schemaDigest===void 0&&(u.push(E.id),n.push({severity:"warning",area:"workflow",message:`[resolver/pinNotStamped] Knoten "${E.id}" pinnt ${I}:${A} ohne Stempel \u2014 ob er \u201Econtract\u201C oder \u201Econtracts\u201C liefert und welche Parameter er hat, pr\xFCft erst \`offer plan\` (stempelt den Pin von der Umgebung).`}));for(let E of l.nodes)E.type!=="governedDocument"||E.production!=="template"||E.templateStamp!==void 0||n.push({severity:"warning",area:"workflow",message:`[template/notStamped] Knoten "${E.id}" f\xFCllt die Vorlage ${pr(E)??"\u2014"} ohne ihre Parameter \u2014 welche Felder sie hat, pr\xFCft erst \`offer plan\` (stempelt sie vom Vorlagen-Datensatz der Umgebung).`});for(let{node:E,form:A}of AM(e))n.push({severity:"warning",area:"workflow",message:`[formExports/stale] Knoten "${E}": der Stempel formExports passt nicht mehr zum Formular "${A}" \u2014 die Adresspr\xFCfung liest den alten Stand; \`offer workflow restamp-exports\` stempelt ihn neu (publish tut es ohnehin).`});let p=e.index.program?.stages?.map(E=>E.key),m={...H5(e,l),...p===void 0?{}:{stageKeys:new Set(p)}},y=s(E=>{let A=dM(E,{layout:d,wiring:c},m),I=new Set(cM(A));return{issues:A,isError:s(_=>I.has(_)||(_.severity??"error")==="error","isError")}},"blockingOf"),{issues:k,isError:g}=y(l),v=new Set;if(u.length>0){let E=structuredClone(l);for(let T of E.nodes)u.includes(T.id)&&(T.generatorStamp={...T.generatorStamp??{},parts:[{partKey:"?"}]});let A=y(E),I=new Set(A.issues.filter(A.isError).map(Vm)),_=s(T=>u.some(b=>T.includes(`$node.${b}.contract`)),"namesOutput");for(let T of k){let b=Vm(T);g(T)&&!I.has(b)&&_(b)&&v.add(b)}}for(let E of k){let A=Vm(E);if(v.has(A)){n.push({severity:"warning",area:"workflow",message:`[resolver/pinNotStamped \u2192 offer plan] ${A}`});continue}n.push({severity:g(E)?"error":"warning",area:"workflow",message:A})}}let o=e.index.program?.stages,a=o===void 0?void 0:new Set(o.map(l=>l.key));for(let[l,d]of Object.entries(e.smartforms??{})){let c=Rn(d.label);(c==="not-localized"||c.length>0)&&n.push({severity:"error",area:"smartform",message:`${l}: [i18n/missingTranslation] \`label\` muss ein zweisprachiger Text ({ de, en }) sein.`});let u=RM(d);for(let k of fI(u,`smartforms/${l}.json`))n.push({severity:"error",area:"smartform",message:k.de});let p=u,m=Lm(p,{stageKeys:a}),y=new Set(Mm(m));for(let k of m)n.push({severity:y.has(k)||k.severity==="error"?"error":"warning",area:"smartform",message:`${l}: ${Vm(k)}`});for(let k of[...$0(p),...T0(p)])n.push({severity:"error",area:"smartform",message:`${l}: [${k.code}] ${k.path}: ${k.message}`})}if(e.workflow!==void 0){let l=e.workflow.graph,d=new Set(J5(l)),c=new Set(Object.keys(e.smartforms??{}));for(let u of d)c.has(u)||n.push({severity:"error",area:"consistency",message:`form node binds smartForm "${u}" but the bundle carries no smartforms/${u}.json`});for(let u of c)d.has(u)||n.push({severity:"warning",area:"consistency",message:`smartform "${u}" is carried but no form node binds it`})}return n}s(Rt,"validateBundle");async function Yv(e,n,t){let r=Om(t);if(r.length===0)return{rows:[],issues:[]};let i=[...new Map(r.map(({key:c,kind:u,revision:p})=>[`${u}:${c}:${p??"current"}`,{key:c,kind:u,...p===void 0?{}:{revision:p}}])).values()],o=await e.query(x.workflow.getResolverPinStamps,{client:n,unitKey:t.index.links?.unitKey??null,pins:i}).catch(c=>{throw c instanceof Error&&c.message.includes("Could not find public function")?new Error(`offer: ${e.convexUrl} has no workflow:getResolverPinStamps \u2014 that deployment is older than this CLI; release it first (or use a CLI of its release).`,{cause:c}):c}),a=new Map(o.map(c=>[`${c.kind}:${c.key}:${c.revision??"current"}`,c])),l=[],d=[];for(let{node:c,key:u,kind:p,revision:m}of r){let y=a.get(`${p}:${u}:${m??"current"}`);if(y===void 0)throw new Error(`offer: the environment answered no stamp for ${p}:${u}`);if(y.stamp===null){if(y.refusal===null)throw new Error(`offer: the environment answered neither a stamp nor a refusal for ${p}:${u}`);d.push({severity:"error",area:"workflow",message:`[resolver/pinRefused] Knoten "${c.id}": ${y.refusal.de}`});continue}dI(c,structuredClone(y.stamp),{freezeRevision:!0}),l.push({target:`stamp:${c.id}`,detail:y.stamp.parts===void 0?`${p}:${u} Dokument`:`${p}:${u} kombiniert (${y.stamp.parts.map(k=>k.partKey).join(", ")})`})}return{rows:l,issues:d}}s(Yv,"stampResolverPins");async function Hv(e,n,t){let r=(t.workflow?.graph?.nodes??[]).filter(d=>d.type==="governedDocument"&&d.production==="template"),i=[...new Set(r.flatMap(d=>{let c=pr(d);return c===null?[]:[c]}))];if(i.length===0)return{rows:[],issues:[]};let o=new Map((await e.query(x.workflow.getTemplateStamps,{client:n,keys:i})).map(d=>[d.key,d])),a=[],l=[];for(let d of r){let c=pr(d);if(c===null)continue;let u=o.get(c);if(u===void 0)throw new Error(`offer: the environment answered nothing for template ${c}`);if(EL(d,u.parameters),u.parameters!==null){a.push({target:`stamp:${String(d.id)}`,detail:`template:${c} (${u.parameters.fields.length} Parameter)`});continue}l.push({severity:"error",area:"workflow",message:u.exists?`[governedDocument/templateWithoutParameters] Knoten "${String(d.id)}": die Vorlage ${c} deklariert keine Parameter (plexus-cli catalog apply, documentTemplates[].parameters).`:`[governedDocument/unknownTemplate] Knoten "${String(d.id)}": eine Vorlage ${c} gibt es in dieser Umgebung nicht.`})}return{rows:a,issues:l}}s(Hv,"stampTemplatePins");async function OM(e,n,t){let r=je(t),i=await Yv(e,n,r),o=await Hv(e,n,r),a=[...i.rows,...o.rows],l=[...i.issues,...o.issues];if(l.length>0)return{rows:a,refused:l,open:[]};if(a.length===0)throw new Error("offer workflow restamp-pins: the bundle pins no contract generator or package (offer workflow node set-generator) and fills no Word template");Tt(r);let d=a.map(p=>p.target.slice(6)),c=s(p=>d.some(m=>p.includes(`nodes.${m}.`)||p.includes(`node.${m}.`)||p.includes(`"${m}"`)),"onStamped"),u=Rt(r).filter(p=>p.severity==="error"&&c(p.message));return{rows:a,refused:[],open:u}}s(OM,"restampPinsOnDisk");var Q5=z.join("contract","resolver-setup.json"),mi="resolver setup",Sa=s((e,n)=>Cn(e,n,mi),"record"),Ji=s((e,n)=>Ge(e,n,mi),"text");function Z5(e,n){let t=Sa(e,"Datei"),r=Sa(t.contractTemplate,"contractTemplate"),i=Sa(t.resolver,"resolver");return{dir:n,contractTemplate:{key:Ji(r.key,"contractTemplate.key"),name:ft(r.name,"contractTemplate.name",mi,"Vorlagennamen"),file:Ji(r.file,"contractTemplate.file"),role:Ji(r.role,"contractTemplate.role")},revenueAccounts:Pp(t.revenueAccounts,mi),billingItems:Np(t.billingItems,mi),resolver:{key:Ji(i.key,"resolver.key"),name:ft(i.name,"resolver.name",mi,"Generatornamen"),description:i.description===void 0?null:ft(i.description,"resolver.description",mi,"Beschreibungen"),legalText:i.legalText??{},source:Ji(i.source,"resolver.source"),feeGroups:(i.feeGroups===void 0?[]:Ct(i.feeGroups,"resolver.feeGroups",mi)).map((o,a)=>{let l=Sa(o,`resolver.feeGroups[${a}]`);return{key:Ji(l.key,"feeGroup.key"),name:ft(l.name,"feeGroup.name",mi,"Geb\xFChrengruppen"),billingItemKeys:Jv(l.billingItemKeys,"feeGroup.billingItemKeys")}}),billingItemKeys:Jv(i.billingItemKeys??[],"resolver.billingItemKeys"),grantTemplateKeys:Jv(i.grantTemplateKeys??[],"resolver.grantTemplateKeys"),scenarios:X5(i.scenarios??[]),config:Sa(i.config,"resolver.config")}}}s(Z5,"parseResolverSetup");function Jv(e,n){if(!Array.isArray(e)||e.some(t=>typeof t!="string"||t.trim()==="")||new Set(e).size!==e.length)throw new Error(`generator setup: ${n} must be a list of unique keys.`);return e}s(Jv,"stringList");function X5(e){if(!Array.isArray(e)||e.length>20)throw new Error("generator setup: scenarios must be a list of at most 20 reviewed examples.");return e.map(n=>{let t=Sa(n,"scenario");if(!("input"in t)||!("expected"in t))throw new Error("generator setup: each scenario needs input and reviewed expected output.");return{key:Ji(t.key,"scenario.key"),input:t.input,expected:t.expected}})}s(X5,"parseScenarios");function Um(e){let n=z.resolve(e);return Z5(JSON.parse(he(n,"utf8")),z.dirname(n))}s(Um,"readResolverSetup");function eQ(e,n){let t=e;for(let r of n.split(".")){if(typeof t!="object"||t===null||!(r in t))throw new Error(`resolver setup: resolver.config.${n} existiert nicht.`);t=t[r]}return t}s(eQ,"configValue");function PM(e){let n=s(()=>Ji(e.resolver.config.lehrgangsbeginn,"resolver.config.lehrgangsbeginn"),"effectiveFrom"),t=new Set(e.billingItems.map(r=>r.key));return{revenueAccounts:e.revenueAccounts,catalogItemKeys:[...new Set([...Qv(e.resolver.config),...e.resolver.billingItemKeys])].filter(r=>!t.has(r)),billingItems:e.billingItems.map(r=>{if(r.programs!==void 0)throw new Error(`resolver setup: Artikel ${r.key}: "programs" verwaltet nur die Katalog-Datei (plexus-cli catalog), nicht resolver-setup.json.`);if("tree"in r.price)throw new Error(`resolver setup: Artikel ${r.key}: Tarife werden im Katalog verwaltet.`);let i=r.price.amount,o=typeof i=="object"&&i!==null&&typeof i.$config=="string"?eQ(e.resolver.config,i.$config):i;if(typeof o!="number"||!Number.isFinite(o))throw new Error(`resolver setup: Artikel ${r.key}: Preis ist keine Zahl (${JSON.stringify(i)}).`);return{key:r.key,name:r.name,itemType:r.itemType,revenueAccountCode:r.revenueAccount,taxTreatment:r.taxTreatment,config:r.config,price:{amount:o,currency:r.price.currency,effectiveFrom:n(),period:r.price.period}}})}}s(PM,"billingSetupPayload");function NM(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let n=Object.entries(e);if(n.length!==1||n[0][0]!=="$billingItem")return;let t=n[0][1];if(typeof t!="string")throw new Error(`resolver setup: $billingItem ${JSON.stringify(t)} ist kein Schl\xFCssel.`);return t}s(NM,"billingItemRef");function Qv(e){if(Array.isArray(e))return e.flatMap(Qv);if(typeof e!="object"||e===null)return[];let n=NM(e);return n!==void 0?[n]:Object.values(e).flatMap(Qv)}s(Qv,"billingItemRefs");function Zv(e,n,t={}){let r=s(i=>{if(Array.isArray(i))return i.map(r);if(typeof i=="object"&&i!==null){let o=Object.entries(i);if(o.length===1&&o[0][0]==="$grantTemplate"){let l=o[0][1];if(typeof l!="string"||t[l]===void 0)throw new Error(`generator setup: grant template ${String(l)} is not declared.`);return t[l]}let a=NM(i);if(a!==void 0){if(!(a in n))throw new Error(`resolver setup: $billingItem "${a}" ist weder in billingItems deklariert noch ein Katalogartikel.`);return n[a]}return Object.fromEntries(Object.entries(i).map(([l,d])=>[l,r(d)]))}return i},"walk");return r(e)}s(Zv,"renderResolverConfig");function nQ(e,n){let t=Array.isArray(e.documentPlaceholderKeys)?e.documentPlaceholderKeys:[],r=new Set(n.placeholders),i=new Set(t.map(String)),o=[...r].filter(l=>!i.has(l)),a=[...i].filter(l=>!r.has(l));if(o.length>0||a.length>0)throw new Error("resolver setup: resolver.config.documentPlaceholderKeys weicht vom DOCX ab"+(o.length>0?` \u2014 fehlt: ${o.join(", ")}`:"")+(a.length>0?` \u2014 nicht im DOCX: ${a.join(", ")}`:"")+". Liste aus dem DOCX \xFCbernehmen.")}s(nQ,"assertPlaceholderParity");function tQ(e,n){let t=[...e].filter(r=>r.status==="sealed").sort((r,i)=>i.revisionNumber-r.revisionNumber)[0];if(t!==void 0)return t.source===n.source&&t.pinnedDocumentTemplateId===n.documentTemplateId&&Pe(t.config)===Pe(n.config)&&Pe(t.legalText)===Pe(n.legalText)&&Pe([...t.billingItemDefinitionIds].sort())===Pe([...n.billingItemDefinitionIds].sort())&&Pe([...t.grantTemplateIds].sort())===Pe([...n.grantTemplateIds].sort())&&Pe(t.feeGroups)===Pe(n.feeGroups)?t:void 0}s(tQ,"matchingSealedRevision");async function Cd(e,n,t){if(t.resolver.source===null)throw new Error("generator setup requires a self-contained source file.");let r=he(z.join(t.dir,t.resolver.source),"utf8"),i=await zl(z.join(t.dir,t.contractTemplate.file));nQ(t.resolver.config,i);let o=await e.query(x.contractSetup.planBillingSetup,{client:n,...PM(t)}),a=await e.query(x.contractSetup.wordTemplateState,{client:n,configKey:t.contractTemplate.key}),l=a===null||a.sha256!==i.sha256,d=await e.query(x.contractConfig.model,{client:n}),c={};for(let A of t.resolver.grantTemplateKeys){let I=d.grantTemplates.find(_=>_.configKey===A);if(I===void 0)throw new Error(`Unknown grant template ${A}`);c[A]=I.id}let u=Zv(t.resolver.config,o.billingItemIds,c),m=(await e.query(x.contractGeneratorRevisions.model,{client:n})).find(A=>A.definition.key===t.resolver.key),y=m?.currentRevisionId?await e.query(x.contractGeneratorRevisions.detail,{client:n,id:m.currentRevisionId}):null,k=m?.revisions.find(A=>A.status==="draft"),g=k?await e.query(x.contractGeneratorRevisions.detail,{client:n,id:k.id}):null,v=l||y===null?void 0:tQ([y],{source:r,config:u,legalText:t.resolver.legalText,documentTemplateId:a.id,billingItemDefinitionIds:t.resolver.billingItemKeys.map(A=>o.billingItemIds[A]??`not-created:${A}`),grantTemplateIds:Object.values(c),feeGroups:t.resolver.feeGroups.map(A=>({key:A.key,name:A.name,billingItemDefinitionIds:A.billingItemKeys.map(I=>o.billingItemIds[I]??`not-created:${I}`)}))}),E=o.rows.map(A=>({step:A.kind,target:A.key,action:A.action,detail:A.detail}));return E.push({step:"wordTemplate",target:t.contractTemplate.key,action:l?"create":"same",detail:z.basename(i.file)}),E.push({step:"generatorRevision",target:t.resolver.key,action:v?"same":"create",detail:v?`Current sealed revision ${v.revisionNumber}`:"Save source, review scenarios and seal a new revision"}),{rows:E,docx:i,source:r,renderedConfig:u,billingItemIds:o.billingItemIds,grantTemplateIds:c,head:m,current:y,draft:g,match:v,template:{documentTemplateId:a?.id??null,upload:l}}}s(Cd,"planResolverSetup");async function _M(e,n,t){let r=await Cd(e,n,t);if(r.rows.every(p=>p.action==="same"))return{rows:r.rows,pin:{key:t.resolver.key,kind:"generator"}};if(!r.match&&t.resolver.scenarios.length===0)throw new Error("A new generator revision requires reviewed scenarios.");let i=await e.mutation(x.contractSetup.applyBillingSetup,{client:n,...PM(t)});if(r.match)return{rows:r.rows,pin:{key:t.resolver.key,kind:"generator"}};let o=r.template.upload?await Op(e,n,r.docx,{name:t.contractTemplate.name,role:t.contractTemplate.role,configKey:t.contractTemplate.key}):r.template.documentTemplateId,a=r.draft?._id;if(a===void 0)if(r.head===void 0)a=(await e.mutation(x.contractGeneratorRevisions.create,{client:n,key:t.resolver.key,name:t.resolver.name,description:t.resolver.description??{de:"",en:""}})).revisionId;else{if(r.current===null)throw new Error("Generator has neither draft nor sealed revision.");a=await e.mutation(x.contractGeneratorRevisions.cloneDraft,{client:n,id:r.current._id})}let l=await e.query(x.contractGeneratorRevisions.detail,{client:n,id:a}),d=await e.mutation(x.contractGeneratorRevisions.save,{client:n,id:a,expectedSourceRevision:l.sourceRevision,config:Zv(t.resolver.config,i.billingItemIds,r.grantTemplateIds),legalText:t.resolver.legalText,documentTemplateId:o}),c=await e.action(x.contractGeneratorRevisionActions.saveSource,{client:n,id:a,expectedSourceRevision:d,source:r.source,billingItemDefinitionIds:t.resolver.billingItemKeys.map(p=>i.billingItemIds[p]),grantTemplateIds:Object.values(r.grantTemplateIds),feeGroups:t.resolver.feeGroups.map(p=>({key:p.key,name:p.name,billingItemDefinitionIds:p.billingItemKeys.map(m=>i.billingItemIds[m])}))});if(c.diagnostics.length||c.sourceRevision===null||c.artifactHash===null)throw new Error(c.diagnostics.join(`
|
|
11260
|
+
`)}`);let c=Gv(l),u=Array.isArray(i.formExports)?i.formExports.map(m=>m.key):null,p=i.formExports===void 0||Pe(i.formExports)!==Pe(c);i.formExports=c,r.push({node:i.id,form:o,before:u,after:c.map(m=>m.key),changed:p})}for(let i of t)if(i.type==="form"&&vt(i)&&"formExports"in i){let o=i.formExports?.map(a=>a.key)??null;delete i.formExports,r.push({node:i.id,form:"(adoptForm)",before:o,after:[],changed:!0})}return r}s(Bm,"restampFormExports");function AM(e){let n=e.workflow?.graph?.nodes??[];return xM(n).flatMap(({node:t,slug:r})=>{if(t.formExports===void 0)return[];let i=e.smartforms?.[r];if(i===void 0)return[];let o=i;return SM(o).length>0?[]:Pe(t.formExports)===Pe(Gv(o))?[]:[{node:t.id,form:r}]})}s(AM,"staleFormExports");var Wv=["string","number","boolean","date"];function EM(e,n){let t="offer form field export";for(let r of Kt(e)){let i=[...r.fields,...(r.groups??[]).flatMap(a=>a.fields)].find(a=>a.key===n.key);if(i!==void 0){if(n.type!==void 0)throw new Error(`${t}: --type is for a computed field; "${n.key}" is an entered ${i.type} field and exports as its own type`);if(n.on&&!gM(i.type))throw new Error(`${t}: "${n.key}" is a ${i.type} field \u2014 that type has no exported value (export.invalid-type)`);if(n.on&&i.multiple===!0)throw new Error(`${t}: "${n.key}" is a multi-select \u2014 N picked options are no single leaf (export.multiple-enum)`);let a=i.export===!0,l=i;return n.on?l.export=!0:delete l.export,{kind:"field",before:a,after:n.on}}let o=(r.computed??[]).find(a=>a.key===n.key);if(o!==void 0){let a=o.export===!0,l=o;if(!n.on){if(n.type!==void 0)throw new Error(`${t}: --type goes with an export, not with --off`);return delete l.export,delete l.exportType,{kind:"computed",before:a,after:!1}}let d=n.type??o.exportType;if(d===void 0)throw new Error(`${t}: "${n.key}" is a computed field \u2014 name its type with --type (${Wv.join("|")}); an expression has none to infer`);if(!Wv.includes(d))throw new Error(`${t}: --type "${d}" is no computed export type (${Wv.join("|")})`);return l.export=!0,l.exportType=d,{kind:"computed",before:a,after:!0}}if((r.repeated??[]).some(a=>a.itemTemplate.some(l=>l.key===n.key)))throw new Error(`${t}: "${n.key}" sits in a repeated block \u2014 a row value is no per-application leaf (export.in-repeated)`)}throw new Error(`${t}: the form has no field "${n.key}"`)}s(EM,"setFieldExport");function TM(e,n,t){let r="offer workflow node set-generator",i=vM(e,n,r);if(Im(i)!=="resolver")throw new Error(`${r}: "${n}" generates no contract from a generator (${i.type==="governedDocument"?`production ${String(i.production)}`:String(i.type)}) \u2014 a pin belongs on a governedDocument with production resolver`);let a=t.key.trim();if(a==="")throw new Error(`${r}: the ${t.kind} key is empty`);let l=ni(i),d=l!==null&&l.key===a&&l.kind===t.kind&&l.revision===void 0,c=!d&&"generatorStamp"in i;c&&delete i.generatorStamp,i.inputs={...i.inputs??{},[Vn]:{kind:"literal",value:{kind:t.kind,key:a}}};let u=d?[]:Object.keys(i.inputs).filter(p=>p!==Vn&&p!==_t);return{before:l,after:{key:a,kind:t.kind},droppedStamp:c,keptParameterCells:u}}s(TM,"setGeneratorPin");function $M(e,n,t){let r="offer workflow node set-cockpit-fields",i=vM(e,n,r),o=Im(i);if(o!=="resolver"&&o!=="template")throw new Error(`${r}: "${n}" fills no document from a generator or a Word template (${i.type==="governedDocument"?`production ${String(i.production)}`:String(i.type)})`);if(!(o==="resolver"?ni(i)!==null:pr(i)!==null))throw new Error(o==="resolver"?`${r}: "${n}" names no generator yet \u2014 name one first (offer workflow node set-generator)`:`${r}: "${n}" names no Word template yet \u2014 name one first (inputs.documentTemplate)`);let l=new Set;for(let p of t){if(l.has(p))throw new Error(`${r}: --fields names "${p}" twice`);l.add(p)}let d={...i.inputs??{}},c=Object.keys(d).filter(p=>d[p]?.kind==="cockpit"),u=t.flatMap(p=>{let m=d[p];return m===void 0||m.kind==="cockpit"||m.kind==="unset"?[]:[{field:p,cell:m}]});for(let p of c)l.has(p)||delete d[p];for(let p of t)d[p]={kind:"cockpit"};return i.inputs=d,{pin:o,before:c,after:[...t],replaced:u}}s($M,"setCockpitFields");var W5=new Set(["graph","progressLayout","progressWiring"]);function RM(e){let{label:n,...t}=e;return t}s(RM,"definitionOf");function Y5(e){let n=[];for(let o of Object.keys(e))W5.has(o)||n.push(`workflow.json: unknown key \`${o}\` \u2014 the file carries only graph, progressLayout, progressWiring. Delete the line.`);let t=e.graph;if(t===null||typeof t!="object"||Array.isArray(t))return n.push("workflow.json: `graph` must be an object."),n;for(let o of Object.keys(t)){if(uI.has(o))continue;let a=o==="id"||o==="label"?" (the title is the offer's, bundle.yaml `label`)":o==="dataFlow"?" (publish derives it)":"";n.push(`workflow.json: \`graph.${o}\` is no longer part of the workflow graph${a}. Delete the line.`)}let r=t;Array.isArray(r.nodes)?n.push(...fM(r.nodes).map(o=>`workflow.json: ${o}`)):n.push("workflow.json: `graph.nodes` must be a list."),r.assignmentRules===void 0&&n.push("workflow.json: `graph.assignmentRules` is required (who becomes responsible).");let i=e.progressWiring;return i!=null&&typeof i=="object"&&"layoutId"in i&&n.push("workflow.json: `progressWiring.layoutId` is no longer part of the wiring (the layout is the workflow's own). Delete the line."),n}s(Y5,"workflowShapeIssues");function IM(e){let n=e.nodes??[],t=new Map;for(let r of n){let i=iO(r);i!==void 0&&t.set(r.id,i)}return t}s(IM,"formNodeSlugById");function H5(e,n){let t=e.smartforms??{},r=new Map;for(let[i,o]of IM(n)){let a=t[o];if(a===void 0)return;r.set(i,RM(a))}return xN(r)}s(H5,"readinessContext");function J5(e){return[...IM(e).values()]}s(J5,"formNodeSlugs");function Vm(e){let n=e.code?`[${e.code}] `:"",t=e.path?`${e.path}: `:"",r=e.reason??e.message;return`${n}${t}${r===void 0?JSON.stringify(e):r.de}`}s(Vm,"describe");function Rt(e){let n=[];for(let l of df(e.manifest))n.push({severity:"error",area:"manifest",message:l});let t=Rn(e.index.label);(t==="not-localized"||t.length>0)&&n.push({severity:"error",area:"manifest",message:`[i18n/missingTranslation] bundle.yaml label fehlt in: ${t==="not-localized"?"de, en":t.join(", ")} \u2014 jeder angezeigte Text braucht Deutsch und Englisch.`});let{manifest:r,workflow:i}=e.index.slugs;i!==void 0&&i!==r&&n.push({severity:"error",area:"workflow",message:`slugs.workflow '${i}' must equal slugs.manifest '${r}' \u2014 the workflow belongs to the offer family, and export writes the family key`});for(let l of dm(e.index.program?.stages??[]))n.push({severity:"error",area:"program",message:l.message.de});for(let l of fm(e.index.program?.runs??[]))n.push({severity:"error",area:"program",message:l.message.de});for(let l of pm(e.index.program?.runs??[],e.index.program?.stages?.map(d=>d.key)))n.push({severity:"error",area:"program",message:l});if(e.workflow!==void 0){for(let E of Y5(e.workflow))n.push({severity:"error",area:"workflow",message:E});let l=e.workflow.graph,d=e.workflow.progressLayout,c=e.workflow.progressWiring;if(d!==void 0)for(let E of cI(d))n.push({severity:"error",area:"workflow",message:E});let u=[];for(let{node:E,key:A,kind:I}of Om(e))E.generatorStamp?.schemaDigest===void 0&&(u.push(E.id),n.push({severity:"warning",area:"workflow",message:`[resolver/pinNotStamped] Knoten "${E.id}" pinnt ${I}:${A} ohne Stempel \u2014 ob er \u201Econtract\u201C oder \u201Econtracts\u201C liefert und welche Parameter er hat, pr\xFCft erst \`offer plan\` (stempelt den Pin von der Umgebung).`}));for(let E of l.nodes)E.type!=="governedDocument"||E.production!=="template"||E.templateStamp!==void 0||n.push({severity:"warning",area:"workflow",message:`[template/notStamped] Knoten "${E.id}" f\xFCllt die Vorlage ${pr(E)??"\u2014"} ohne ihre Parameter \u2014 welche Felder sie hat, pr\xFCft erst \`offer plan\` (stempelt sie vom Vorlagen-Datensatz der Umgebung).`});for(let{node:E,form:A}of AM(e))n.push({severity:"warning",area:"workflow",message:`[formExports/stale] Knoten "${E}": der Stempel formExports passt nicht mehr zum Formular "${A}" \u2014 die Adresspr\xFCfung liest den alten Stand; \`offer workflow restamp-exports\` stempelt ihn neu (publish tut es ohnehin).`});let p=e.index.program?.stages?.map(E=>E.key),m={...H5(e,l),...p===void 0?{}:{stageKeys:new Set(p)}},y=s(E=>{let A=dM(E,{layout:d,wiring:c},m),I=new Set(cM(A));return{issues:A,isError:s(_=>I.has(_)||(_.severity??"error")==="error","isError")}},"blockingOf"),{issues:k,isError:g}=y(l),v=new Set;if(u.length>0){let E=structuredClone(l);for(let T of E.nodes)u.includes(T.id)&&(T.generatorStamp={...T.generatorStamp??{},parts:[{partKey:"?"}]});let A=y(E),I=new Set(A.issues.filter(A.isError).map(Vm)),_=s(T=>u.some(b=>T.includes(`$node.${b}.contract`)),"namesOutput");for(let T of k){let b=Vm(T);g(T)&&!I.has(b)&&_(b)&&v.add(b)}}for(let E of k){let A=Vm(E);if(v.has(A)){n.push({severity:"warning",area:"workflow",message:`[resolver/pinNotStamped \u2192 offer plan] ${A}`});continue}n.push({severity:g(E)?"error":"warning",area:"workflow",message:A})}}let o=e.index.program?.stages,a=o===void 0?void 0:new Set(o.map(l=>l.key));for(let[l,d]of Object.entries(e.smartforms??{})){let c=Rn(d.label);(c==="not-localized"||c.length>0)&&n.push({severity:"error",area:"smartform",message:`${l}: [i18n/missingTranslation] \`label\` muss ein zweisprachiger Text ({ de, en }) sein.`});let u=RM(d);for(let k of fI(u,`smartforms/${l}.json`))n.push({severity:"error",area:"smartform",message:k.de});let p=u,m=Lm(p,{stageKeys:a}),y=new Set(Mm(m));for(let k of m)n.push({severity:y.has(k)||k.severity==="error"?"error":"warning",area:"smartform",message:`${l}: ${Vm(k)}`});for(let k of[...$0(p),...T0(p)])n.push({severity:"error",area:"smartform",message:`${l}: [${k.code}] ${k.path}: ${k.message}`})}if(e.workflow!==void 0){let l=e.workflow.graph,d=new Set(J5(l)),c=new Set(Object.keys(e.smartforms??{}));for(let u of d)c.has(u)||n.push({severity:"error",area:"consistency",message:`form node binds smartForm "${u}" but the bundle carries no smartforms/${u}.json`});for(let u of c)d.has(u)||n.push({severity:"warning",area:"consistency",message:`smartform "${u}" is carried but no form node binds it`})}return n}s(Rt,"validateBundle");async function Yv(e,n,t){let r=Om(t);if(r.length===0)return{rows:[],issues:[]};let i=[...new Map(r.map(({key:c,kind:u,revision:p})=>[`${u}:${c}:${p??"current"}`,{key:c,kind:u,...p===void 0?{}:{revision:p}}])).values()],o=await e.query(x.workflow.getResolverPinStamps,{client:n,unitKey:t.index.links?.unitKey??null,pins:i}).catch(c=>{throw c instanceof Error&&c.message.includes("Could not find public function")?new Error(`offer: ${e.convexUrl} has no workflow:getResolverPinStamps \u2014 that deployment is older than this CLI; release it first (or use a CLI of its release).`,{cause:c}):c}),a=new Map(o.map(c=>[`${c.kind}:${c.key}:${c.revision??"current"}`,c])),l=[],d=[];for(let{node:c,key:u,kind:p,revision:m}of r){let y=a.get(`${p}:${u}:${m??"current"}`);if(y===void 0)throw new Error(`offer: the environment answered no stamp for ${p}:${u}`);if(y.stamp===null){if(y.refusal===null)throw new Error(`offer: the environment answered neither a stamp nor a refusal for ${p}:${u}`);d.push({severity:"error",area:"workflow",message:`[resolver/pinRefused] Knoten "${c.id}": ${y.refusal.de}`});continue}dI(c,structuredClone(y.stamp),{freezeRevision:!0}),l.push({target:`stamp:${c.id}`,detail:y.stamp.parts===void 0?`${p}:${u} Dokument`:`${p}:${u} kombiniert (${y.stamp.parts.map(k=>k.partKey).join(", ")})`})}return{rows:l,issues:d}}s(Yv,"stampResolverPins");async function Hv(e,n,t){let r=(t.workflow?.graph?.nodes??[]).filter(d=>d.type==="governedDocument"&&d.production==="template"),i=[...new Set(r.flatMap(d=>{let c=pr(d);return c===null?[]:[c]}))];if(i.length===0)return{rows:[],issues:[]};let o=new Map((await e.query(x.workflow.getTemplateStamps,{client:n,keys:i})).map(d=>[d.key,d])),a=[],l=[];for(let d of r){let c=pr(d);if(c===null)continue;let u=o.get(c);if(u===void 0)throw new Error(`offer: the environment answered nothing for template ${c}`);if(EL(d,u.parameters),u.parameters!==null){a.push({target:`stamp:${String(d.id)}`,detail:`template:${c} (${u.parameters.fields.length} Parameter)`});continue}l.push({severity:"error",area:"workflow",message:u.exists?`[governedDocument/templateWithoutParameters] Knoten "${String(d.id)}": die Vorlage ${c} deklariert keine Parameter (plexus-cli catalog apply, documentTemplates[].parameters).`:`[governedDocument/unknownTemplate] Knoten "${String(d.id)}": eine Vorlage ${c} gibt es in dieser Umgebung nicht.`})}return{rows:a,issues:l}}s(Hv,"stampTemplatePins");async function OM(e,n,t){let r=je(t),i=await Yv(e,n,r),o=await Hv(e,n,r),a=[...i.rows,...o.rows],l=[...i.issues,...o.issues];if(l.length>0)return{rows:a,refused:l,open:[]};if(a.length===0)throw new Error("offer workflow restamp-pins: the bundle pins no contract generator or package (offer workflow node set-generator) and fills no Word template");Tt(r);let d=a.map(p=>p.target.slice(6)),c=s(p=>d.some(m=>p.includes(`nodes.${m}.`)||p.includes(`node.${m}.`)||p.includes(`"${m}"`)),"onStamped"),u=Rt(r).filter(p=>p.severity==="error"&&c(p.message));return{rows:a,refused:[],open:u}}s(OM,"restampPinsOnDisk");var Q5=z.join("contract","resolver-setup.json"),mi="resolver setup",Sa=s((e,n)=>Cn(e,n,mi),"record"),Ji=s((e,n)=>Ge(e,n,mi),"text");function Z5(e,n){let t=Sa(e,"Datei"),r=Sa(t.contractTemplate,"contractTemplate"),i=Sa(t.resolver,"resolver");return{dir:n,contractTemplate:{key:Ji(r.key,"contractTemplate.key"),name:ft(r.name,"contractTemplate.name",mi,"Vorlagennamen"),file:Ji(r.file,"contractTemplate.file"),role:Ji(r.role,"contractTemplate.role")},revenueAccounts:Pp(t.revenueAccounts,mi),billingItems:Np(t.billingItems,mi),resolver:{key:Ji(i.key,"resolver.key"),name:ft(i.name,"resolver.name",mi,"Generatornamen"),description:i.description===void 0?null:ft(i.description,"resolver.description",mi,"Beschreibungen"),legalText:i.legalText??{},source:Ji(i.source,"resolver.source"),feeGroups:(i.feeGroups===void 0?[]:Ct(i.feeGroups,"resolver.feeGroups",mi)).map((o,a)=>{let l=Sa(o,`resolver.feeGroups[${a}]`);return{key:Ji(l.key,"feeGroup.key"),name:ft(l.name,"feeGroup.name",mi,"Geb\xFChrengruppen"),billingItemKeys:Jv(l.billingItemKeys,"feeGroup.billingItemKeys")}}),billingItemKeys:Jv(i.billingItemKeys??[],"resolver.billingItemKeys"),grantTemplateKeys:Jv(i.grantTemplateKeys??[],"resolver.grantTemplateKeys"),scenarios:X5(i.scenarios??[]),config:Sa(i.config,"resolver.config")}}}s(Z5,"parseResolverSetup");function Jv(e,n){if(!Array.isArray(e)||e.some(t=>typeof t!="string"||t.trim()==="")||new Set(e).size!==e.length)throw new Error(`generator setup: ${n} must be a list of unique keys.`);return e}s(Jv,"stringList");function X5(e){if(!Array.isArray(e)||e.length>20)throw new Error("generator setup: scenarios must be a list of at most 20 reviewed examples.");return e.map(n=>{let t=Sa(n,"scenario");if(!("input"in t)||!("expected"in t))throw new Error("generator setup: each scenario needs input and reviewed expected output.");return{key:Ji(t.key,"scenario.key"),input:t.input,expected:t.expected}})}s(X5,"parseScenarios");function Um(e){let n=z.resolve(e);return Z5(JSON.parse(he(n,"utf8")),z.dirname(n))}s(Um,"readResolverSetup");function eQ(e,n){let t=e;for(let r of n.split(".")){if(typeof t!="object"||t===null||!(r in t))throw new Error(`resolver setup: resolver.config.${n} existiert nicht.`);t=t[r]}return t}s(eQ,"configValue");function PM(e){let n=s(()=>Ji(e.resolver.config.lehrgangsbeginn,"resolver.config.lehrgangsbeginn"),"effectiveFrom"),t=new Set(e.billingItems.map(r=>r.key));return{revenueAccounts:e.revenueAccounts,catalogItemKeys:[...new Set([...Qv(e.resolver.config),...e.resolver.billingItemKeys])].filter(r=>!t.has(r)),billingItems:e.billingItems.map(r=>{if(r.programs!==void 0)throw new Error(`resolver setup: Artikel ${r.key}: "programs" verwaltet nur die Katalog-Datei (plexus-cli catalog), nicht resolver-setup.json.`);if("tree"in r.price)throw new Error(`resolver setup: Artikel ${r.key}: Tarife werden im Katalog verwaltet.`);let i=r.price.amount,o=typeof i=="object"&&i!==null&&typeof i.$config=="string"?eQ(e.resolver.config,i.$config):i;if(typeof o!="number"||!Number.isFinite(o))throw new Error(`resolver setup: Artikel ${r.key}: Preis ist keine Zahl (${JSON.stringify(i)}).`);return{key:r.key,name:r.name,itemType:r.itemType,revenueAccountCode:r.revenueAccount,taxTreatment:r.taxTreatment,config:r.config,price:{amount:o,currency:r.price.currency,effectiveFrom:n(),period:r.price.period}}})}}s(PM,"billingSetupPayload");function NM(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let n=Object.entries(e);if(n.length!==1||n[0][0]!=="$billingItem")return;let t=n[0][1];if(typeof t!="string")throw new Error(`resolver setup: $billingItem ${JSON.stringify(t)} ist kein Schl\xFCssel.`);return t}s(NM,"billingItemRef");function Qv(e){if(Array.isArray(e))return e.flatMap(Qv);if(typeof e!="object"||e===null)return[];let n=NM(e);return n!==void 0?[n]:Object.values(e).flatMap(Qv)}s(Qv,"billingItemRefs");function Zv(e,n,t={}){let r=s(i=>{if(Array.isArray(i))return i.map(r);if(typeof i=="object"&&i!==null){let o=Object.entries(i);if(o.length===1&&o[0][0]==="$grantTemplate"){let l=o[0][1];if(typeof l!="string"||t[l]===void 0)throw new Error(`generator setup: grant template ${String(l)} is not declared.`);return t[l]}let a=NM(i);if(a!==void 0){if(!(a in n))throw new Error(`resolver setup: $billingItem "${a}" ist weder in billingItems deklariert noch ein Katalogartikel.`);return n[a]}return Object.fromEntries(Object.entries(i).map(([l,d])=>[l,r(d)]))}return i},"walk");return r(e)}s(Zv,"renderResolverConfig");function nQ(e,n){let t=Array.isArray(e.documentPlaceholderKeys)?e.documentPlaceholderKeys:[],r=new Set(n.placeholders),i=new Set(t.map(String)),o=[...r].filter(l=>!i.has(l)),a=[...i].filter(l=>!r.has(l));if(o.length>0||a.length>0)throw new Error("resolver setup: resolver.config.documentPlaceholderKeys weicht vom DOCX ab"+(o.length>0?` \u2014 fehlt: ${o.join(", ")}`:"")+(a.length>0?` \u2014 nicht im DOCX: ${a.join(", ")}`:"")+". Liste aus dem DOCX \xFCbernehmen.")}s(nQ,"assertPlaceholderParity");function tQ(e,n){let t=[...e].filter(r=>r.status==="sealed").sort((r,i)=>i.revisionNumber-r.revisionNumber)[0];if(t!==void 0)return t.coverLetter===void 0&&t.source===n.source&&t.pinnedDocumentTemplateId===n.documentTemplateId&&Pe(t.config)===Pe(n.config)&&Pe(t.legalText)===Pe(n.legalText)&&Pe([...t.billingItemDefinitionIds].sort())===Pe([...n.billingItemDefinitionIds].sort())&&Pe([...t.grantTemplateIds].sort())===Pe([...n.grantTemplateIds].sort())&&Pe(t.feeGroups)===Pe(n.feeGroups)?t:void 0}s(tQ,"matchingSealedRevision");async function Cd(e,n,t){if(t.resolver.source===null)throw new Error("generator setup requires a self-contained source file.");let r=he(z.join(t.dir,t.resolver.source),"utf8"),i=await zl(z.join(t.dir,t.contractTemplate.file));nQ(t.resolver.config,i);let o=await e.query(x.contractSetup.planBillingSetup,{client:n,...PM(t)}),a=await e.query(x.contractSetup.wordTemplateState,{client:n,configKey:t.contractTemplate.key}),l=a===null||a.sha256!==i.sha256,d=await e.query(x.contractConfig.model,{client:n}),c={};for(let A of t.resolver.grantTemplateKeys){let I=d.grantTemplates.find(_=>_.configKey===A);if(I===void 0)throw new Error(`Unknown grant template ${A}`);c[A]=I.id}let u=Zv(t.resolver.config,o.billingItemIds,c),m=(await e.query(x.contractGeneratorRevisions.model,{client:n})).find(A=>A.definition.key===t.resolver.key),y=m?.currentRevisionId?await e.query(x.contractGeneratorRevisions.detail,{client:n,id:m.currentRevisionId}):null,k=m?.revisions.find(A=>A.status==="draft"),g=k?await e.query(x.contractGeneratorRevisions.detail,{client:n,id:k.id}):null,v=l||y===null?void 0:tQ([y],{source:r,config:u,legalText:t.resolver.legalText,documentTemplateId:a.id,billingItemDefinitionIds:t.resolver.billingItemKeys.map(A=>o.billingItemIds[A]??`not-created:${A}`),grantTemplateIds:Object.values(c),feeGroups:t.resolver.feeGroups.map(A=>({key:A.key,name:A.name,billingItemDefinitionIds:A.billingItemKeys.map(I=>o.billingItemIds[I]??`not-created:${I}`)}))}),E=o.rows.map(A=>({step:A.kind,target:A.key,action:A.action,detail:A.detail}));return E.push({step:"wordTemplate",target:t.contractTemplate.key,action:l?"create":"same",detail:z.basename(i.file)}),E.push({step:"generatorRevision",target:t.resolver.key,action:v?"same":"create",detail:v?`Current sealed revision ${v.revisionNumber}`:"Save source, review scenarios and seal a new revision"}),{rows:E,docx:i,source:r,renderedConfig:u,billingItemIds:o.billingItemIds,grantTemplateIds:c,head:m,current:y,draft:g,match:v,template:{documentTemplateId:a?.id??null,upload:l}}}s(Cd,"planResolverSetup");async function _M(e,n,t){let r=await Cd(e,n,t);if(r.rows.every(p=>p.action==="same"))return{rows:r.rows,pin:{key:t.resolver.key,kind:"generator"}};if(!r.match&&t.resolver.scenarios.length===0)throw new Error("A new generator revision requires reviewed scenarios.");let i=await e.mutation(x.contractSetup.applyBillingSetup,{client:n,...PM(t)});if(r.match)return{rows:r.rows,pin:{key:t.resolver.key,kind:"generator"}};let o=r.template.upload?await Op(e,n,r.docx,{name:t.contractTemplate.name,role:t.contractTemplate.role,configKey:t.contractTemplate.key}):r.template.documentTemplateId,a=r.draft?._id;if(a===void 0)if(r.head===void 0)a=(await e.mutation(x.contractGeneratorRevisions.create,{client:n,key:t.resolver.key,name:t.resolver.name,description:t.resolver.description??{de:"",en:""}})).revisionId;else{if(r.current===null)throw new Error("Generator has neither draft nor sealed revision.");a=await e.mutation(x.contractGeneratorRevisions.cloneDraft,{client:n,id:r.current._id})}let l=await e.query(x.contractGeneratorRevisions.detail,{client:n,id:a}),d=await e.mutation(x.contractGeneratorRevisions.save,{client:n,id:a,expectedSourceRevision:l.sourceRevision,config:Zv(t.resolver.config,i.billingItemIds,r.grantTemplateIds),legalText:t.resolver.legalText,documentTemplateId:o}),c=await e.action(x.contractGeneratorRevisionActions.saveSource,{client:n,id:a,expectedSourceRevision:d,source:r.source,billingItemDefinitionIds:t.resolver.billingItemKeys.map(p=>i.billingItemIds[p]),grantTemplateIds:Object.values(r.grantTemplateIds),feeGroups:t.resolver.feeGroups.map(p=>({key:p.key,name:p.name,billingItemDefinitionIds:p.billingItemKeys.map(m=>i.billingItemIds[m])}))});if(c.diagnostics.length||c.sourceRevision===null||c.artifactHash===null)throw new Error(c.diagnostics.join(`
|
|
11258
11261
|
`));if(d=c.sourceRevision,await e.mutation(x.contractGeneratorRevisions.approveScenarios,{client:n,id:a,expectedSourceRevision:d,artifactHash:c.artifactHash,scenarios:Zv({scenarios:t.resolver.scenarios},i.billingItemIds,r.grantTemplateIds).scenarios}),await e.mutation(x.contractGeneratorRevisions.seal,{client:n,id:a,expectedSourceRevision:d}),(await Cd(e,n,t)).match===void 0)throw new Error("The sealed revision does not match the declarative setup.");return{rows:r.rows,pin:{key:t.resolver.key,kind:"generator"}}}s(_M,"applyResolverSetup");async function Xv(e,n,t){let r=z.join(t.dir,Q5);if(!Se(r)||t.workflow===void 0)return[];let i=Um(r);if((await Cd(e,n,i)).match===void 0)throw new Error("Apply the generator setup before publishing the offer.");return[]}s(Xv,"pinSetupRevisions");function rQ(e){if(e.label===void 0)return;let n=e.label;if(typeof n!="object"||n===null||typeof n.de!="string"||typeof n.en!="string")throw new Error(`node "${e.id}": label ${JSON.stringify(e.label)} is not a { de, en } text`);return{de:n.de,en:n.en}}s(rQ,"nodeText");function Dd(e,n){let t=[],r=[],i=[],o={},a=n.progressEvents??[],l=rQ(e);for(let d of a){let c=`${e.id}.${d}`,u=n.progressDefaults?.[d];if(u===void 0)throw new Error(`node "${e.id}" (${e.type}) emits progress-event "${d}", but its node spec declares no progress default for it`);let p=e.type==="decision"&&d==="released"&&l!==void 0,m=p?l:u.label,y=u.tone,k={id:c,label:m,tone:y,external:u.external};u.terminal&&(k.terminal=!0),t.push(k),r.push({match:{nodeId:e.id},event:d,bus:"process",state:c});let g=u.phase,v=iQ(g,e.id),E=i.find(A=>A.id===v);if(E)E.states=[...E.states,c];else{let A={id:v,label:p?m:g.label,tone:y,states:[c]};g.track&&(A.track=g.track),g.defaultCollapsed&&(A.defaultCollapsed=!0),g.waitlist&&(A.waitlist=!0),i.push(A)}u.terminal&&(o[c]=u.terminal)}return{states:t,mappings:r,columns:i,terminalSemantics:o}}s(Dd,"deriveProgressEntriesForNode");function Gm(e){return Object.entries(e).filter(([,n])=>n.outcome==="approved").map(([n])=>n)}s(Gm,"seatedTerminalStates");function iQ(e,n){return e.scope==="global"?`col.${e.key}`:`${n}.${e.key}`}s(iQ,"columnIdFor");function CM(e,n){let t=s(i=>(i.states??[]).some(o=>n.terminalStateIds.has(o)),"isTerminal"),r=s(i=>{let o=n.columnNodeId(i);return(o!==void 0?n.nodeOrder.get(o):void 0)??Number.POSITIVE_INFINITY},"topoOf");return e.map((i,o)=>({c:i,idx:o,term:t(i)?1:0,topo:r(i)})).sort((i,o)=>i.term-o.term||i.topo-o.topo||i.idx-o.idx).map(i=>i.c)}s(CM,"orderProcessColumns");var ir=s((e,n)=>({de:e,en:n}),"lt"),nx=gs("start",[]),zm=gs("form",[nx]),ex=gs("end",[nx,zm]);function oQ(e){let n=[Dd({id:zm,type:"form",label:ir("Formular","Form")},Vo.form),Dd({id:ex,type:"end",label:ir("Ende","End")},Vo.end)],t=[],r=[],i=[],o={};for(let c of n){t.push(...c.states),i.push(...c.mappings),o={...o,...c.terminalSemantics};for(let u of c.columns){let p=r.find(m=>m.id===u.id);p?p.states=[...new Set([...p.states,...u.states])]:r.push(u)}}let a=Gm(o);return{layout:{id:`layout.${e}.starter`,buses:[{key:"process",states:t,terminalSemantics:o,holdsSeat:a,commitsSeat:a,boards:[{id:"prozess",label:ir("Prozess","Process"),audience:"both",columns:r}]}]},wiring:{mappings:i}}}s(oQ,"buildStarterProgress");function DM(e){let{slug:n,title:t,tenant:r,unit:i,responsible:o}=e,a=n,l=`${n}-form`,d=`${n}-flow`,c=[{id:nx,type:"eventTrigger",label:ir("Start","Start"),sublabel:ir("Eingang externer Bewerber-Aktion","Incoming external applicant action"),next:{bewerbungOffen:{to:zm}}},{id:zm,type:"form",label:t,sublabel:ir("Bewerbungsformular","Application form"),inputs:{smartForm:{kind:"literal",value:l}},outcomes:[{id:"standard",label:ir("Standard","Standard")}],next:{standard:{to:ex}},notifications:{submitted:{templateId:"applicant.applicationSubmitted"}}},{id:ex,type:"end",label:ir("Ende \xB7 Angenommen","End \xB7 Accepted"),inputs:{applicationOutcome:{kind:"literal",value:"approved"},dataDecision:{kind:"literal",value:"commit"}}}],u={nodes:c,assignmentRules:XP(nN([{slot:"responsible",rules:[{when:ji,assign:{kind:"creator"}},{when:null,assign:{kind:"person",configKey:o}}]}],Zf({nodes:c})))},{layout:p,wiring:m}=oQ(d),y={id:va("section.applicant"),label:ir("Antragsteller","Applicant"),fields:[{key:ot("applicant.vorname"),label:ir("Vorname","First name"),kind:"control",type:"string",required:!0,bucket:"applicant"},{key:ot("applicant.nachname"),label:ir("Nachname","Last name"),kind:"control",type:"string",required:!0,bucket:"applicant"}]},k=[{id:Yi("standard"),label:ir("Standard","Standard"),when:"true",output:{fields:[{path:ot("applicant.vorname")},{path:ot("applicant.nachname")}],includeForm:!0}}],g={sections:[y],effects:[],outcomes:k},v={};return{index:{module:"admission",tenant:r,label:t,slugs:{manifest:a,workflow:a},smartforms:{[l]:{}},...i?{links:{unitKey:i}}:{}},manifest:v,smartforms:{[l]:{label:t,...g}},workflow:{graph:u,progressLayout:p,progressWiring:m}}}s(DM,"buildSkeletonBundle");var Wo={same:"\xB7",create:"+",change:"~",absent:"\u2205"};async function Dn(e,n,t){let i=(await e.query(x.workflow.listManifests,{client:n})).find(o=>o.offerKey===t);if(!i)throw new Error(`offer: no offer "${t}" in tenant "${n}"`);return i}s(Dn,"findOfferHandle");function st(e,n,t){return e.query(x.programAdmin.getAngebotConfig,{client:n,offerKey:t,includeArchived:!0})}s(st,"loadConfig");function tx(e,n){let t=e.units.find(r=>r.key===n);if(!t)throw new Error(`offer: unit "${n}" not found. Available keys: ${e.units.map(r=>r.key??"(no key)").join(", ")||"(none)"}`);return t.unitId}s(tx,"resolveUnitId");function Aa(e,n){let t=FM(e),r=e.runs.find(i=>i.key===pi(t,n));if(!r)throw new Error(`offer: run "${n}" not found. Available keys: ${e.runs.map(i=>FF(t,i.key)).join(", ")||"(none)"}`);return r.runId}s(Aa,"resolveRunId");function Ea(e,n){let t=FM(e),r=e.stages.find(i=>i.key===Zb(t,n));if(!r)throw new Error(`offer: level "${n}" not found. Available keys: ${e.stages.map(i=>Vr(t,i.key)).join(", ")||"(none)"}`);return r.stageId}s(Ea,"resolveStageId");function FM(e){if(e.programKey===null)throw new Error("offer: the offer has no program yet \u2014 link a unit first");return e.programKey}s(FM,"requireProgramKey");async function rx(e,n,t,r){await e.mutation(x.programAdmin.ensurePedagogyUnit,{client:n,unitId:r}),await e.mutation(x.programAdmin.createProgramForAngebot,{client:n,offerKey:t,unitId:r})}s(rx,"linkUnit");function Yo(e,n){if(n===void 0)return;let t=Number(n);if(!Number.isInteger(t)||t<0)throw new Error(`offer: --${e} must be a non-negative integer`);return t}s(Yo,"parsePositiveInt");var Ta=s((e="Offer slug (required)")=>f.String("--offer",{description:e}),"offerOption"),ix=s(()=>f.String("--slug",{hidden:!0}),"retiredSlugOption");function ox(e){if(e.retiredSlug!==void 0){if(e.offer!==void 0&&e.offer!==e.retiredSlug)throw new vn(`--offer "${e.offer}" and --slug "${e.retiredSlug}" name different offers \u2014 pass only --offer.`);return an(e.context.stderr,"--slug","--offer"),e.retiredSlug}if(e.offer===void 0)throw new vn("Missing --offer <slug>.");return e.offer}s(ox,"requireOffer");var nn=class extends D{static{s(this,"OfferCommand")}offer=Ta();retiredSlug=ix();#e;get offerSlug(){return this.#e??=ox(this),this.#e}};var Fd=class extends nn{static{s(this,"OfferExportCommand")}static paths=[["offer","export"]];static usage=$.Usage({category:"Offer",description:"Pull an offer's published generation (manifest + smartforms + workflow + program) into a bundle; --draft pulls the draft"});offer=Ta("Manifest slug to export (required)");out=f.String("--out",{required:!0,description:"Output bundle directory (refused when not empty, unless --force)"});force=kn();draft=f.Boolean("--draft",!1,{description:"Export the editable draft instead of the published generation (the live head, else the staged candidate)"});async execute(){let n=rk(this.out,this.force),t=await this.caller(),r=this.requireTenant(t),{bundle:i,generation:o,revision:a}=await m0(t,r,this.offerSlug,this.draft?"draft":"published");return Tt({...i,dir:n}),this.print({exported:`${r}/${this.offerSlug}`,generation:o,revision:a,dir:n},l=>[{key:"exported",value:l.exported},{key:"generation",value:`${l.generation} (revision ${l.revision})`},{key:"dir",value:l.dir}]),0}},Ld=class extends xe{static{s(this,"OfferInitCommand")}static paths=[["offer","init"]];static usage=$.Usage({category:"Offer",description:"Scaffold a complete, publishable, minimal linear offer bundle on disk"});offer=Ta("New offer slug (identity key) (required)");retiredSlug=ix();title=f.String("--title",{required:!0,description:"Bare offer title in German (= program/form label), e.g. 'Grundschule'. Do NOT include the run/year or levels \u2014 those are separate entities (program_runs.name / program_stages) shown alongside the offer, never composed into the label."});titleEn=f.String("--title-en",{required:!0,description:"The same title in English, e.g. 'Primary School' (every name a reader sees has both)"});tenant=f.String("--tenant",{required:!0,description:"Tenant slug (stamped on bundle.yaml)"});unit=f.String("--unit",{description:"Pedagogic unit (school) the portal resolves the offer through \u2014 its config key"});responsible=f.String("--responsible",{required:!0,description:"configKey of the staff member a self-service application goes to (the process slot\u2019s \u201Esonst\u201C row); a staff start goes to its creator"});template=f.String("--template","basic",{description:"Scaffold template (only 'basic')"});out=f.String("--out",{description:"Output directory (default: offers/<tenant>/<slug>; refused when not empty, unless --force)"});force=kn();async execute(){let n=ox(this);if(this.template!=="basic")throw new Error(`offer init: unknown template "${this.template}" (only 'basic')`);let t=rk(this.out??z.join("offers",this.tenant,n),this.force),r=DM({slug:n,title:Hn({de:this.title,en:this.titleEn},"offer init",{de:"--title",en:"--title-en"}),tenant:this.tenant,responsible:this.responsible,template:"basic",...this.unit?{unit:this.unit}:{}});return Tt({...r,dir:t}),this.print({created:`${this.tenant}/${n}`,dir:t},i=>[{key:"created",value:i.created},{key:"dir",value:i.dir},{key:"next",value:`plexus offer validate --dir ${i.dir}`}]),0}},Md=class extends xe{static{s(this,"OfferValidateCommand")}static paths=[["offer","validate"]];static usage=$.Usage({category:"Offer",description:"Run the publish-gate validators locally against a bundle (no deployment)"});dir=f.String("--dir",{required:!0,description:"Bundle directory"});async execute(){let n=je(this.dir),t=Rt(n);return this.print(t,r=>r.length===0?[{severity:"ok",area:"-",message:"local validation clean"}]:r.map(i=>({severity:i.severity,area:i.area,message:i.message}))),t.some(r=>r.severity==="error")?1:0}},qd=class extends D{static{s(this,"OfferPlanCommand")}static paths=[["offer","plan"]];static usage=$.Usage({category:"Offer",description:"Read-only: local validation (resolver pins stamped from the environment, as publish would) + remote\u2194local diff (create/change/same)"});dir=f.String("--dir",{required:!0,description:"Bundle directory"});async execute(){let n=je(this.dir),t=await this.caller(),{pins:r,stamps:i,issues:o}=await LM(t,n),a=await Lv(t,n);return this.print({validation:o,resolverPins:r,resolverStamps:i.rows,diff:a},()=>[...o.map(l=>({kind:`local:${l.severity}`,target:l.area,detail:l.message})),...r.map(l=>({kind:"=",target:l.target,detail:l.detail})),...i.rows.map(l=>({kind:"=",target:l.target,detail:l.detail})),{kind:Wo[a.manifest],target:"manifest",detail:a.manifest},...Object.entries(a.smartforms).map(([l,d])=>({kind:Wo[d],target:`smartform:${l}`,detail:d})),{kind:Wo[a.workflow],target:"workflow",detail:a.workflow},...MM(a).map(l=>({kind:l.icon,target:l.target,detail:l.status})),...qM(a).map(l=>({kind:l.icon,target:l.target,detail:l.status})),...KM(a).map(l=>({kind:l.icon,target:l.target,detail:l.status})),...jM(a).map(l=>({kind:l.icon,target:l.target,detail:l.status}))]),o.some(l=>l.severity==="error")?1:0}},Kd=class extends D{static{s(this,"OfferDiffCommand")}static paths=[["offer","diff"]];static usage=$.Usage({category:"Offer",description:"Read-only remote\u2194local drift (no local validation)"});dir=f.String("--dir",{required:!0,description:"Bundle directory"});async execute(){let n=je(this.dir),t=await this.caller(),r=await Xv(t,n.index.tenant,n),i=await Lv(t,n);return this.print(i,()=>[...r.map(o=>({icon:"=",target:o.target,status:o.detail})),{icon:Wo[i.manifest],target:"manifest",status:i.manifest},...Object.entries(i.smartforms).map(([o,a])=>({icon:Wo[a],target:`smartform:${o}`,status:a})),{icon:Wo[i.workflow],target:"workflow",status:i.workflow},...MM(i),...qM(i),...KM(i),...jM(i)]),0}};async function LM(e,n){let t=await Xv(e,n.index.tenant,n),r=await Yv(e,n.index.tenant,n),i=await Hv(e,n.index.tenant,n);return{pins:t,stamps:{...r,rows:[...r.rows,...i.rows]},issues:[...r.issues,...i.issues,...Rt(n)]}}s(LM,"validateOnEnvironment");function MM(e){return e.addresses===null?[]:u0(e.addresses)}s(MM,"addressRows");function qM(e){let n={insert:"+",update:"~",archive:"-"};return e.stages.map(t=>({icon:n[t.op],target:`stage:${t.key}`,status:um(t)}))}s(qM,"stageRows");function KM(e){return e.capacities.map(n=>({icon:"~",target:`cap:${n.run}\xD7${n.stageKey}`,status:mm(n)}))}s(KM,"capacityRows");function jM(e){if(e.publishPending===null)return[];let n=e.externalHeadRevision===null?"none":`v${e.externalHeadRevision}`;return[{icon:e.publishPending?"!":"=",target:"publish",status:e.publishPending?`pending (draft v${e.draftRevision} ahead of live ${n})`:`up to date (live ${n})`}]}s(jM,"publishPendingRows");var jd=class extends D{static{s(this,"OfferApplyCommand")}static paths=[["offer","apply"]];static usage=$.Usage({category:"Offer",description:"Idempotent create/update; with --publish, release the draft when it differs from what is live"});dir=f.String("--dir",{required:!0,description:"Bundle directory"});publish=f.Boolean("--publish",!1,{description:"Release the draft when it says something the live generation does not"});stage=f.String("--stage","external",{description:"Publish stage: 'external' (default, goes live) or 'internal' (stage as the testable candidate only)"});async execute(){if(this.stage!=="internal"&&this.stage!=="external")throw new Error(`offer: --stage must be 'internal' or 'external' (got "${this.stage}")`);let n=je(this.dir),t=await this.caller(),{pins:r,stamps:i,issues:o}=await LM(t,n);for(let d of[...r,...i.rows])this.context.stderr.write(` = ${d.target}: ${d.detail}
|
|
11259
11262
|
`);for(let d of o)d.severity==="warning"&&this.context.stderr.write(` warning ${d.area}: ${d.message}
|
|
11260
11263
|
`);let a=o.filter(d=>d.severity==="error");if(a.length>0){let d=this.publish?"\u2716":"\u26A0";for(let c of a)this.context.stderr.write(` ${d} ${c.area}: ${c.message}
|
|
@@ -11433,6 +11436,6 @@ ${t.length} unusable ${o}:
|
|
|
11433
11436
|
`),r.length>0&&this.context.stdout.write(` ${r.length} linkable \u2014 plexus-cli platform users relink-auth <email>
|
|
11434
11437
|
`),i.length>0&&this.context.stdout.write(` ${i.length} without any login account \u2014 plexus-cli platform users provision --tenant <slug> --email <email> --name <name>
|
|
11435
11438
|
`)}else this.context.stdout.write(`No unusable identities.
|
|
11436
|
-
`);return t.length>0?1:0}},GE=class extends lr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=$.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let t=await(await this.caller()).mutation(x.platformAdmin.relinkAuthAccount,{email:this.email}),r=t.changed?`Relinked ${this.email} to live auth account ${t.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(t,r),0}};function wB(e,n){if(e===n)throw new Error("Pass exactly one of --on or --off.");return e}s(wB,"requireOnOff");var kB=[RE,IE,OE,PE,NE,_E,CE,DE,FE,LE,tu,ME,qE,KE,jE,BE,VE,UE,GE];function bB(e){return e.de??e.en??Object.values(e)[0]??""}s(bB,"titleDe");function TZ(e){return{id:e._id,kind:e.kind,status:e.status,title:bB(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(TZ,"row");var $Z=["id","kind","status","title","assignee","group","outcome"],YE=class extends D{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=$.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.list,{client:t,...this.mine?{mine:!0}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(TZ),$Z),0}},HE=class extends D{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=$.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.get,{client:t,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${t}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:bB(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},JE=class extends D{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=$.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.createManual,{client:t,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},QE=class extends D{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=$.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.complete,{client:t,workItemId:this.workItemId,...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},ZE=class extends D{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=$.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.assign,{client:t,workItemId:this.workItemId,...this.user?{userId:this.user}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},vB=[YE,HE,JE,QE,ZE];var ru=[...NR,...CC,...GC,...WD,...zD,...kF,...TF,...EF,...gB,...kB,...hB,...nj,...aj,...wC,...hF,...iB,...OR,...oI,...rC,...IF,...RF,...NF,..._F,...pF,...XD,...vB,...JM,...qq,...XK,...Kq,...jj,...Hj,...lj,...yj,...bj,...Aj,...Tj,...Zj,...lB,...YR];for(let e of ru){let n=e.paths?.[0];n===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:XT(e.usage.category,n.join(" "))})}var xB="0.1.126";function SB(){return ru.flatMap(e=>(e.paths??[]).map(n=>{let t=n.join(" "),r=HT[so(t)];return{path:t,effect:ao(t),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,n)=>e.path.localeCompare(n.path))}s(SB,"plexusCommandCatalog");import Zo from"node:path";function RZ(e){let n=dn()?.workspaceRoot??process.cwd(),t=Zo.resolve(n,e),r=Zo.relative(n,t);if(Zo.isAbsolute(e)||r===".."||r.startsWith(`..${Zo.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:t,relative:r}}s(RZ,"workspacePath");function IZ(e){let{absolute:n,relative:t}=RZ(e.path??".");if(e.operation==="list"){if(!Se(n))return{files:[]};let r=[],i=s(o=>{for(let a of Rr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=Zo.join(o,a.name);if(a.isDirectory()?i(l):r.push(Zo.relative(n,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(n),{files:r.sort()}}if(!t)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=he(n);if(r.length>10*1024*1024)throw new Error("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:t,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new Error("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:t,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new Error("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new Error("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new Error("plexus: the edited file exceeds 10 MB.");return ze(n,a,"utf8"),{path:t,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new Error("plexus: file content is missing or too large.");return Fn(Zo.dirname(n),{recursive:!0}),ze(n,e.content,"utf8"),{path:t,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return ts(n),{path:t,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(IZ,"plexusWorkspace");function AB(e){return s(async function(t,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=ll[t];if(!o||!Object.hasOwn(ll,t))throw new Error("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new Error("plexus: unexpected tool argument.");if(t==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new Error("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(t==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(Ug,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Ug[i.path],skillHash:Qu}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new Error("plexus: invalid workspace input.");return IZ(i)},"executePlexusAgentTool")}s(AB,"createPlexusAgentToolExecutor");var Ih=AB({inspectCommand:TB,executeCommand:$B});function Oh(){let e=new ss({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:xB});e.register(Ga.HelpCommand),e.register(Ga.VersionCommand);for(let t of ru)e.register(t);async function n(t,r){let i;try{i=e.process(t,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return NZ(i,r.stderr??process.stderr),e.run(i,r)}return s(n,"run"),{process(t,r){return e.process(t,r)},run:n,async runExit(t,r){process.exitCode=await n(t,r)}}}s(Oh,"createPlexusCli");function NZ(e,n){let t=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&t!==r&&Ja[t]===r&&an(n,t,r),t in Ja&&ao(t)==="confirm"&&!Qa(e)&&n.write(`plexus-cli: \`${Ja[t]}\` only prints its plan without --confirm \u2014 nothing was changed.
|
|
11439
|
+
`);return t.length>0?1:0}},GE=class extends lr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=$.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let t=await(await this.caller()).mutation(x.platformAdmin.relinkAuthAccount,{email:this.email}),r=t.changed?`Relinked ${this.email} to live auth account ${t.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(t,r),0}};function wB(e,n){if(e===n)throw new Error("Pass exactly one of --on or --off.");return e}s(wB,"requireOnOff");var kB=[RE,IE,OE,PE,NE,_E,CE,DE,FE,LE,tu,ME,qE,KE,jE,BE,VE,UE,GE];function bB(e){return e.de??e.en??Object.values(e)[0]??""}s(bB,"titleDe");function TZ(e){return{id:e._id,kind:e.kind,status:e.status,title:bB(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(TZ,"row");var $Z=["id","kind","status","title","assignee","group","outcome"],YE=class extends D{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=$.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.list,{client:t,...this.mine?{mine:!0}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(TZ),$Z),0}},HE=class extends D{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=$.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.get,{client:t,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${t}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:bB(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},JE=class extends D{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=$.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.createManual,{client:t,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},QE=class extends D{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=$.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.complete,{client:t,workItemId:this.workItemId,...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},ZE=class extends D{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=$.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.assign,{client:t,workItemId:this.workItemId,...this.user?{userId:this.user}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},vB=[YE,HE,JE,QE,ZE];var ru=[...NR,...CC,...GC,...WD,...zD,...kF,...TF,...EF,...gB,...kB,...hB,...nj,...aj,...wC,...hF,...iB,...OR,...oI,...rC,...IF,...RF,...NF,..._F,...pF,...XD,...vB,...JM,...qq,...XK,...Kq,...jj,...Hj,...lj,...yj,...bj,...Aj,...Tj,...Zj,...lB,...YR];for(let e of ru){let n=e.paths?.[0];n===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:XT(e.usage.category,n.join(" "))})}var xB="0.1.128";function SB(){return ru.flatMap(e=>(e.paths??[]).map(n=>{let t=n.join(" "),r=HT[so(t)];return{path:t,effect:ao(t),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,n)=>e.path.localeCompare(n.path))}s(SB,"plexusCommandCatalog");import Zo from"node:path";function RZ(e){let n=dn()?.workspaceRoot??process.cwd(),t=Zo.resolve(n,e),r=Zo.relative(n,t);if(Zo.isAbsolute(e)||r===".."||r.startsWith(`..${Zo.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:t,relative:r}}s(RZ,"workspacePath");function IZ(e){let{absolute:n,relative:t}=RZ(e.path??".");if(e.operation==="list"){if(!Se(n))return{files:[]};let r=[],i=s(o=>{for(let a of Rr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=Zo.join(o,a.name);if(a.isDirectory()?i(l):r.push(Zo.relative(n,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(n),{files:r.sort()}}if(!t)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=he(n);if(r.length>10*1024*1024)throw new Error("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:t,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new Error("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:t,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new Error("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new Error("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new Error("plexus: the edited file exceeds 10 MB.");return ze(n,a,"utf8"),{path:t,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new Error("plexus: file content is missing or too large.");return Fn(Zo.dirname(n),{recursive:!0}),ze(n,e.content,"utf8"),{path:t,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return ts(n),{path:t,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(IZ,"plexusWorkspace");function AB(e){return s(async function(t,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=ll[t];if(!o||!Object.hasOwn(ll,t))throw new Error("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new Error("plexus: unexpected tool argument.");if(t==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new Error("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(t==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(Ug,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Ug[i.path],skillHash:Qu}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new Error("plexus: invalid workspace input.");return IZ(i)},"executePlexusAgentTool")}s(AB,"createPlexusAgentToolExecutor");var Ih=AB({inspectCommand:TB,executeCommand:$B});function Oh(){let e=new ss({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:xB});e.register(Ga.HelpCommand),e.register(Ga.VersionCommand);for(let t of ru)e.register(t);async function n(t,r){let i;try{i=e.process(t,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return NZ(i,r.stderr??process.stderr),e.run(i,r)}return s(n,"run"),{process(t,r){return e.process(t,r)},run:n,async runExit(t,r){process.exitCode=await n(t,r)}}}s(Oh,"createPlexusCli");function NZ(e,n){let t=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&t!==r&&Ja[t]===r&&an(n,t,r),t in Ja&&ao(t)==="confirm"&&!Qa(e)&&n.write(`plexus-cli: \`${Ja[t]}\` only prints its plan without --confirm \u2014 nothing was changed.
|
|
11437
11440
|
`)}s(NZ,"noteRetiredPath");function TB(e){let n=Oh().process(Fa(e),{executePlexusAgentTool:Ih}),t=n.path.join(" ");if(t.startsWith("agent "))throw new Error("plexus: nested agent transports are not allowed.");let r=SB().find(l=>l.path===t);if(!r){if(t===""||t==="--help"||t==="--version")return{path:t,writes:!1,host:"shared"};throw new Error(`plexus: command ${t} has no host classification.`)}let i=n,o=r.effect==="callKind"?tm(ma(ha),i.fn??"",i.kind):void 0,a=Mu(t,{confirm:Qa(n),callKind:o});return{...r,writes:a}}s(TB,"inspectPlexusCommand");async function $B(e,n){if(n)return nT(n,()=>$B(e));if(!Array.isArray(e.argv)||e.argv.length===0||e.argv.length>128||e.argv.some(l=>typeof l!="string"||l.length>128e3)||(e.stdin?.length??0)>1e6)throw new Error("plexus: invalid command invocation.");let t="",r="",i=Oh();if(dn()){let l=TB(e.argv);if(l.host==="terminal")throw new Error(`plexus: this command requires a local machine. ${l.reason??""}`)}return{exitCode:await i.run(Fa(e.argv),{executePlexusAgentTool:Ih,stdin:PZ.from(e.stdin===void 0?[]:[e.stdin]),stdout:new EB({write(l,d,c){t+=String(l),c()}}),stderr:new EB({write(l,d,c){r+=String(l),c()}})}),stdout:t,stderr:r}}s($B,"executePlexusCommand");sT({source:_Z.join(import.meta.dirname,"skill")});Oh().runExit(Fa(process.argv.slice(2)),{executePlexusAgentTool:Ih});
|
|
11438
11441
|
//# sourceMappingURL=cli.mjs.map
|